Merge pull request #11819 from spowelljr/fixKubectlDirectCall

windows: support renaming binary to `kubectl.exe` and  running as kubectl
pull/11856/head
Sharif Elgamal 2021-07-01 11:03:04 -07:00 committed by GitHub
commit 99ba231b50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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)

View File

@ -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 {