From 6d57b28fddef39c0eeffd95de266cd37a2dbfdb0 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 3 Jun 2019 20:27:26 -0700 Subject: [PATCH 1/3] changing string driver name to checked type --- cmd/minikube/cmd/delete.go | 2 +- cmd/minikube/cmd/env.go | 3 ++- cmd/minikube/cmd/mount.go | 2 +- cmd/minikube/cmd/ssh.go | 3 ++- pkg/drivers/none/none.go | 3 ++- pkg/minikube/cluster/cluster.go | 4 ++-- pkg/minikube/drivers/none/driver.go | 2 +- pkg/minikube/machine/client.go | 4 ++-- 8 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index c0c897798408..096886842316 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -56,7 +56,7 @@ associated files.`, } // In the case of "none", we want to uninstall Kubernetes as there is no VM to delete - if err == nil && cc.MachineConfig.VMDriver == "none" { + if err == nil && cc.MachineConfig.VMDriver == constants.DriverNone { kc := cc.KubernetesConfig bsName := viper.GetString(cmdcfg.Bootstrapper) console.OutStyle(console.Resetting, "Uninstalling Kubernetes %s using %s ...", kc.KubernetesVersion, bsName) diff --git a/cmd/minikube/cmd/env.go b/cmd/minikube/cmd/env.go index 8bd4cad6042d..cf4d669178a2 100644 --- a/cmd/minikube/cmd/env.go +++ b/cmd/minikube/cmd/env.go @@ -35,6 +35,7 @@ import ( "github.com/spf13/cobra" "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/config" + "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/machine" ) @@ -342,7 +343,7 @@ var dockerEnvCmd = &cobra.Command{ if err != nil { exit.WithError("Error getting host", err) } - if host.Driver.DriverName() == "none" { + if host.Driver.DriverName() == constants.DriverNone { exit.Usage(`'none' driver does not support 'minikube docker-env' command`) } hostSt, err := cluster.GetHostStatus(api) diff --git a/cmd/minikube/cmd/mount.go b/cmd/minikube/cmd/mount.go index ec9d452bba07..a91d38a2660d 100644 --- a/cmd/minikube/cmd/mount.go +++ b/cmd/minikube/cmd/mount.go @@ -102,7 +102,7 @@ var mountCmd = &cobra.Command{ if err != nil { exit.WithError("Error loading api", err) } - if host.Driver.DriverName() == "none" { + if host.Driver.DriverName() == constants.DriverNone { exit.Usage(`'none' driver does not support 'minikube mount' command`) } var ip net.IP diff --git a/cmd/minikube/cmd/ssh.go b/cmd/minikube/cmd/ssh.go index ab79e950dd54..e791f6933095 100644 --- a/cmd/minikube/cmd/ssh.go +++ b/cmd/minikube/cmd/ssh.go @@ -23,6 +23,7 @@ import ( "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/console" + "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/machine" ) @@ -42,7 +43,7 @@ var sshCmd = &cobra.Command{ if err != nil { exit.WithError("Error getting host", err) } - if host.Driver.DriverName() == "none" { + if host.Driver.DriverName() == constants.DriverNone { exit.Usage("'none' driver does not support 'minikube ssh' command") } err = cluster.CreateSSHShell(api, args) diff --git a/pkg/drivers/none/none.go b/pkg/drivers/none/none.go index 76ca08f08223..ec2218f4d777 100644 --- a/pkg/drivers/none/none.go +++ b/pkg/drivers/none/none.go @@ -27,10 +27,11 @@ import ( "k8s.io/apimachinery/pkg/util/net" pkgdrivers "k8s.io/minikube/pkg/drivers" // TODO(tstromberg): Extract CommandRunner into its own package "k8s.io/minikube/pkg/minikube/bootstrapper" + "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/cruntime" ) -const driverName = "none" +const driverName = constants.DriverNone // cleanupPaths are paths to be removed by cleanup, and are used by both kubeadm and minikube. var cleanupPaths = []string{ diff --git a/pkg/minikube/cluster/cluster.go b/pkg/minikube/cluster/cluster.go index 740db7973e09..4d4b2cf310af 100644 --- a/pkg/minikube/cluster/cluster.go +++ b/pkg/minikube/cluster/cluster.go @@ -72,7 +72,7 @@ func init() { // CacheISO downloads and caches ISO. func CacheISO(config cfg.MachineConfig) error { - if config.VMDriver != "none" { + if config.MachineConfig.VMDriver == constants.DriverNone { if err := config.Downloader.CacheMinikubeISOFromURL(config.MinikubeISO); err != nil { return err } @@ -154,7 +154,7 @@ func configureHost(h *host.Host, e *engine.Options) error { } } - if h.Driver.DriverName() != "none" { + if h.Driver.DriverName() != constants.DriverNone { if err := h.ConfigureAuth(); err != nil { return &util.RetriableError{Err: errors.Wrap(err, "Error configuring auth on host")} } diff --git a/pkg/minikube/drivers/none/driver.go b/pkg/minikube/drivers/none/driver.go index 5e7c66d022ce..6233a91251ae 100644 --- a/pkg/minikube/drivers/none/driver.go +++ b/pkg/minikube/drivers/none/driver.go @@ -28,7 +28,7 @@ import ( func init() { if err := registry.Register(registry.DriverDef{ - Name: "none", + Name: constants.DriverNone, Builtin: true, ConfigCreator: createNoneHost, DriverCreator: func() drivers.Driver { diff --git a/pkg/minikube/machine/client.go b/pkg/minikube/machine/client.go index b238665e631d..bdd6abc1122a 100644 --- a/pkg/minikube/machine/client.go +++ b/pkg/minikube/machine/client.go @@ -189,7 +189,7 @@ func (api *LocalClient) Create(h *host.Host) error { { "waiting", func() error { - if h.Driver.DriverName() == "none" { + if h.Driver.DriverName() == constants.DriverNone { return nil } return mcnutils.WaitFor(drivers.MachineInState(h.Driver, state.Running)) @@ -198,7 +198,7 @@ func (api *LocalClient) Create(h *host.Host) error { { "provisioning", func() error { - if h.Driver.DriverName() == "none" { + if h.Driver.DriverName() == constants.DriverNone { return nil } pv := provision.NewBuildrootProvisioner(h.Driver) From 79ba9a17a2ea573ce67fed7eaa34892270b53d98 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 3 Jun 2019 20:32:29 -0700 Subject: [PATCH 2/3] typo --- pkg/minikube/cluster/cluster.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/minikube/cluster/cluster.go b/pkg/minikube/cluster/cluster.go index 4d4b2cf310af..aa1fe9f82bbe 100644 --- a/pkg/minikube/cluster/cluster.go +++ b/pkg/minikube/cluster/cluster.go @@ -72,7 +72,7 @@ func init() { // CacheISO downloads and caches ISO. func CacheISO(config cfg.MachineConfig) error { - if config.MachineConfig.VMDriver == constants.DriverNone { + if config.VMDriver == constants.DriverNone { if err := config.Downloader.CacheMinikubeISOFromURL(config.MinikubeISO); err != nil { return err } From 7c8a0e224bc91c21342de6cbedbb4664d2be049d Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 4 Jun 2019 09:25:06 -0700 Subject: [PATCH 3/3] fix mistake logic --- pkg/minikube/cluster/cluster.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/minikube/cluster/cluster.go b/pkg/minikube/cluster/cluster.go index aa1fe9f82bbe..33fa7060d290 100644 --- a/pkg/minikube/cluster/cluster.go +++ b/pkg/minikube/cluster/cluster.go @@ -72,7 +72,7 @@ func init() { // CacheISO downloads and caches ISO. func CacheISO(config cfg.MachineConfig) error { - if config.VMDriver == constants.DriverNone { + if config.VMDriver != constants.DriverNone { if err := config.Downloader.CacheMinikubeISOFromURL(config.MinikubeISO); err != nil { return err }