in cmd/minikube/cmd/root.go [80:161]
func Execute() {
defer audit.Log(time.Now())
// Check whether this is a windows binary (.exe) running inisde WSL.
if runtime.GOOS == "windows" && detect.IsMicrosoftWSL() {
var found = false
for _, a := range os.Args {
if a == "--force" {
found = true
break
}
}
if !found {
exit.Message(reason.WrongBinaryWSL, "You are trying to run a windows .exe binary inside WSL. For better integration please use a Linux binary instead (Download at https://minikube.sigs.k8s.io/docs/start/.). Otherwise if you still want to do this, you can do it using --force")
}
}
if runtime.GOOS == "darwin" && detect.IsAmd64M1Emulation() {
out.Boxed("You are trying to run the amd64 binary on an M1 system.\nPlease consider running the darwin/arm64 binary instead.\nDownload at {{.url}}",
out.V{"url": notify.DownloadURL(version.GetVersion(), "darwin", "arm64")})
}
_, 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
profile := ""
for i, a := range os.Args {
if a == "--context" {
if len(os.Args) > i+1 {
profile = fmt.Sprintf("--profile=%s", os.Args[i+1])
}
break
} else if strings.HasPrefix(a, "--context=") {
context := strings.Split(a, "=")[1]
profile = fmt.Sprintf("--profile=%s", context)
break
}
}
if profile != "" {
os.Args = append([]string{RootCmd.Use, callingCmd, profile, "--"}, os.Args[1:]...)
} else {
os.Args = append([]string{RootCmd.Use, callingCmd, "--"}, os.Args[1:]...)
}
}
for _, c := range RootCmd.Commands() {
c.Short = translate.T(c.Short)
c.Long = translate.T(c.Long)
c.Flags().VisitAll(func(f *pflag.Flag) {
f.Usage = translate.T(f.Usage)
})
c.SetUsageTemplate(usageTemplate())
}
RootCmd.Short = translate.T(RootCmd.Short)
RootCmd.Long = translate.T(RootCmd.Long)
RootCmd.Flags().VisitAll(func(f *pflag.Flag) {
f.Usage = translate.T(f.Usage)
})
if runtime.GOOS != "windows" {
// add minikube binaries to the path
targetDir := localpath.MakeMiniPath("bin")
addToPath(targetDir)
}
// Universally ensure that we never speak to the wrong DOCKER_HOST
if err := oci.PointToHostDockerDaemon(); err != nil {
klog.Errorf("oci env: %v", err)
}
if err := oci.PointToHostPodman(); err != nil {
klog.Errorf("oci env: %v", err)
}
if err := RootCmd.Execute(); err != nil {
// Cobra already outputs the error, typically because the user provided an unknown command.
defer os.Exit(reason.ExProgramUsage)
}
}