提交 bdac73d2 编写于 作者: H hetong07

Put the environment check as a separate if-else clause, and make this check as early as possible.

上级 6d8804e1
......@@ -79,6 +79,20 @@ var RootCmd = &cobra.Command{
func Execute() {
defer audit.Log(time.Now())
// Check whether this is a windows binary (.exe) running inisde WSL.
if runtime.GOOS == "windows" && driver.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 windows .exe binary inside WSL, for better integration please use 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")
}
}
_, callingCmd := filepath.Split(os.Args[0])
if callingCmd == "kubectl" {
......@@ -99,18 +113,8 @@ func Execute() {
} else {
os.Args = append([]string{RootCmd.Use, callingCmd, "--"}, os.Args[1:]...)
}
} else if runtime.GOOS == "windows" && driver.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 windows .exe binary inside WSL, for better integration please use 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")
}
}
for _, c := range RootCmd.Commands() {
c.Short = translate.T(c.Short)
c.Long = translate.T(c.Long)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册