diff --git a/pkg/kubectl/cmd/cmd.go b/pkg/kubectl/cmd/cmd.go index cae1516b80..6440faa646 100644 --- a/pkg/kubectl/cmd/cmd.go +++ b/pkg/kubectl/cmd/cmd.go @@ -22,7 +22,6 @@ import ( "io" "os" "os/exec" - "runtime" "strings" "syscall" @@ -339,12 +338,6 @@ type defaultPluginHandler struct{} // Lookup implements PluginHandler 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) } diff --git a/pkg/kubectl/cmd/plugin/plugin.go b/pkg/kubectl/cmd/plugin/plugin.go index d7df928098..e8463f0455 100644 --- a/pkg/kubectl/cmd/plugin/plugin.go +++ b/pkg/kubectl/cmd/plugin/plugin.go @@ -100,11 +100,7 @@ func (o *PluginListOptions) Complete(cmd *cobra.Command) error { seenPlugins: make(map[string]string, 0), } - path := "PATH" - if runtime.GOOS == "windows" { - path = "path" - } - o.PluginPaths = filepath.SplitList(os.Getenv(path)) + o.PluginPaths = filepath.SplitList(os.Getenv("PATH")) return nil } @@ -230,7 +226,10 @@ func isExecutable(fullPath string) (bool, error) { } 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 false, nil