From a7a0f616421037b21a94d12996fa878dfc37afe2 Mon Sep 17 00:00:00 2001 From: Deepjyoti Mondal Date: Mon, 10 Jun 2019 13:27:25 +0530 Subject: [PATCH] Issue : #4420 - Provide warning message for unnecessary sudo Fixes #4420. If minikue is started with root privilege and vm-driver is not hyperv, then a warning message is displayed. --- cmd/minikube/cmd/start.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index fd45b867190d..5bd83debdc03 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -23,6 +23,7 @@ import ( "net" "os" "os/exec" + "os/user" "path/filepath" "runtime" "strconv" @@ -172,6 +173,13 @@ func runStart(cmd *cobra.Command, args []string) { console.OutStyle(console.Happy, "minikube %s on %s (%s)", version.GetVersion(), runtime.GOOS, runtime.GOARCH) validateConfig() + currentUser, err := user.Current() + + // Display warning if minikube is being started with root and vmDriver is not hyperv + if err == nil && currentUser.Name == "root" && viper.GetString(vmDriver) != "hyperv" { + console.OutStyle(console.WarningType, "Please don't run minikube as root or with 'sudo' privileges. It isn't necessary.") + } + oldConfig, err := cfg.Load() if err != nil && !os.IsNotExist(err) { exit.WithCode(exit.Data, "Unable to load config: %v", err)