Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows: support renaming binary to kubectl.exe and running as kubectl #11819

Merged
merged 1 commit into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/minikube/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cmd/minikube/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"path/filepath"
"regexp"
"strconv"
"strings"

"github.com/spf13/pflag"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 5 additions & 1 deletion test/integration/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down