Skip to content

Commit

Permalink
Provide warning message for unnecessary sudo
Browse files Browse the repository at this point in the history
If minikube is started with root privilege and vm-driver is
not hyperV or none, then a warning message is displayed.
  • Loading branch information
djmgit committed Jun 20, 2019
1 parent eb96756 commit 2cee972
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"net"
"os"
"os/exec"
"os/user"
"path/filepath"
"runtime"
"strconv"
Expand Down Expand Up @@ -172,6 +173,15 @@ 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 {
glog.Errorf("Error getting the current user: %v", err)
} else if currentUser.Name == "root" && !(viper.GetString(vmDriver) == "hyperv" || viper.GetString(vmDriver) == "none") {
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)
Expand Down

0 comments on commit 2cee972

Please sign in to comment.