Skip to content

Commit

Permalink
include fixes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Git-Jiro committed Oct 22, 2020
1 parent 7f6847b commit e065c02
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ func validateUser(drvName string) {
if !viper.GetBool(interactive) {
test := exec.Command("sudo", "-n", "echo", "-n")
if err := test.Run(); err != nil {
exit.Message(reason.Usage, `sudo requires a password, and --interactive=false`)
exit.Message(reason.DrvNeedsRoot, `sudo requires a password, and --interactive=false`)
}
}
return
Expand Down
26 changes: 11 additions & 15 deletions pkg/minikube/command/exec_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,8 @@ func (e *execRunner) Copy(f assets.CopyableFile) error {
dst := path.Join(f.GetTargetDir(), f.GetTargetName())
if _, err := os.Stat(dst); err == nil {
klog.Infof("found %s, removing ...", dst)
switch runtime.GOOS {
case "linux":
if _, err := e.RunCmd(exec.Command("sudo", "rm", "-f", dst)); err != nil {
return errors.Wrapf(err, "error removing file %s", dst)
}
default:
if err := os.Remove(dst); err != nil {
return errors.Wrapf(err, "error removing file %s", dst)
}
if err := e.Remove(f); err != nil {
return errors.Wrapf(err, "error removing file %s", dst)
}
}

Expand Down Expand Up @@ -147,11 +140,14 @@ func (e *execRunner) Copy(f assets.CopyableFile) error {
func (e *execRunner) Remove(f assets.CopyableFile) error {
dst := filepath.Join(f.GetTargetDir(), f.GetTargetName())
klog.Infof("rm: %s", dst)
switch runtime.GOOS {
case "linux":
_, err := e.RunCmd(exec.Command("sudo", "rm", "-f", dst))
return err
default:
return os.Remove(dst)
if err := os.Remove(dst); err != nil {
if !os.IsPermission(err) {
return err
}
_, err = e.RunCmd(exec.Command("sudo", "rm", "-f", dst))
if err != nil {
return err
}
}
return nil
}
7 changes: 1 addition & 6 deletions pkg/minikube/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,7 @@ func BareMetal(name string) bool {

// NeedsRoot returns true if driver needs to run with root privileges
func NeedsRoot(name string) bool {
switch runtime.GOOS {
case "linux":
return false
default:
return name == None
}
return false
}

// NeedsPortForward returns true if driver is unable provide direct IP connectivity
Expand Down

0 comments on commit e065c02

Please sign in to comment.