mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #73469 from dany74q/patch-1
Added windows executable extensions to Kubectl plugins
This commit is contained in:
commit
a780dd78d3
@ -22,7 +22,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
@ -339,12 +338,6 @@ type defaultPluginHandler struct{}
|
|||||||
|
|
||||||
// Lookup implements PluginHandler
|
// Lookup implements PluginHandler
|
||||||
func (h *defaultPluginHandler) Lookup(filename string) (string, error) {
|
func (h *defaultPluginHandler) Lookup(filename string) (string, error) {
|
||||||
// if on Windows, append the "exe" extension
|
|
||||||
// to the filename that we are looking up.
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
filename = filename + ".exe"
|
|
||||||
}
|
|
||||||
|
|
||||||
return exec.LookPath(filename)
|
return exec.LookPath(filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,11 +100,7 @@ func (o *PluginListOptions) Complete(cmd *cobra.Command) error {
|
|||||||
seenPlugins: make(map[string]string, 0),
|
seenPlugins: make(map[string]string, 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
path := "PATH"
|
o.PluginPaths = filepath.SplitList(os.Getenv("PATH"))
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
path = "path"
|
|
||||||
}
|
|
||||||
o.PluginPaths = filepath.SplitList(os.Getenv(path))
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +226,10 @@ func isExecutable(fullPath string) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
if strings.HasSuffix(info.Name(), ".exe") {
|
fileExt := strings.ToLower(filepath.Ext(fullPath))
|
||||||
|
|
||||||
|
switch fileExt {
|
||||||
|
case ".bat", ".cmd", ".com", ".exe":
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user