Unverified Commit a780dd78 authored by Kubernetes Prow Robot's avatar Kubernetes Prow Robot Committed by GitHub

Merge pull request #73469 from dany74q/patch-1

Added windows executable extensions to Kubectl plugins
parents f2ade8e9 aae1944a
...@@ -22,7 +22,6 @@ import ( ...@@ -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{} ...@@ -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 { ...@@ -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) { ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment