Merge pull request #11819 from spowelljr/fixKubectlDirectCall
windows: support renaming binary to `kubectl.exe` and running as kubectlpull/11856/head
commit
99ba231b50
|
@ -100,6 +100,7 @@ func Execute() {
|
|||
}
|
||||
|
||||
_, callingCmd := filepath.Split(os.Args[0])
|
||||
callingCmd = strings.TrimSuffix(callingCmd, ".exe")
|
||||
|
||||
if callingCmd == "kubectl" {
|
||||
// If the user is using the minikube binary as kubectl, allow them to specify the kubectl context without also specifying minikube profile
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
"k8s.io/klog/v2"
|
||||
|
@ -67,6 +68,7 @@ func main() {
|
|||
|
||||
// Don't parse flags when running as kubectl
|
||||
_, callingCmd := filepath.Split(os.Args[0])
|
||||
callingCmd = strings.TrimSuffix(callingCmd, ".exe")
|
||||
parse := callingCmd != "kubectl"
|
||||
setFlags(parse)
|
||||
|
||||
|
|
|
@ -645,7 +645,11 @@ func validateMinikubeKubectl(ctx context.Context, t *testing.T, profile string)
|
|||
func validateMinikubeKubectlDirectCall(ctx context.Context, t *testing.T, profile string) {
|
||||
defer PostMortemLogs(t, profile)
|
||||
dir := filepath.Dir(Target())
|
||||
dstfn := filepath.Join(dir, "kubectl")
|
||||
newName := "kubectl"
|
||||
if runtime.GOOS == "windows" {
|
||||
newName += ".exe"
|
||||
}
|
||||
dstfn := filepath.Join(dir, newName)
|
||||
err := os.Link(Target(), dstfn)
|
||||
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue