diff --git a/cmd/minikube/cmd/root.go b/cmd/minikube/cmd/root.go index 269b74752e39..e85688d8a90b 100644 --- a/cmd/minikube/cmd/root.go +++ b/cmd/minikube/cmd/root.go @@ -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 diff --git a/cmd/minikube/main.go b/cmd/minikube/main.go index e29b9653adc4..496ec6e9fd13 100644 --- a/cmd/minikube/main.go +++ b/cmd/minikube/main.go @@ -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) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index b6ffd91d6566..c161ed34ab05 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -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 {