diff --git a/cmd/minikube/cmd/config/config_test.go b/cmd/minikube/cmd/config/config_test.go index faa7b32ee6..5736897d64 100644 --- a/cmd/minikube/cmd/config/config_test.go +++ b/cmd/minikube/cmd/config/config_test.go @@ -20,6 +20,8 @@ import ( "bytes" "fmt" "testing" + + "k8s.io/minikube/pkg/minikube/constants" ) type configTestCase struct { @@ -47,7 +49,7 @@ var configTestCases = []configTestCase{ "vm-driver": "kvm" }`, config: map[string]interface{}{ - "vm-driver": "kvm", + "vm-driver": constants.DriverKvmOld, "cpus": 4, "disk-size": "20g", "v": 5, diff --git a/cmd/minikube/cmd/config/util_test.go b/cmd/minikube/cmd/config/util_test.go index cd05e88210..8e3e78ce11 100644 --- a/cmd/minikube/cmd/config/util_test.go +++ b/cmd/minikube/cmd/config/util_test.go @@ -25,7 +25,7 @@ import ( ) var minikubeConfig = pkgConfig.MinikubeConfig{ - "vm-driver": "kvm", + "vm-driver": constants.DriverKvmOld, "cpus": 12, "show-libmachine-logs": true, } diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index d7bc068da1..ac4da6c4ac 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -365,7 +365,7 @@ func validateUser() { // 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") { + } else if currentUser.Name == "root" && !(viper.GetString(vmDriver) == constants.DriverHyperv || viper.GetString(vmDriver) == constants.DriverNone) { console.OutStyle(console.WarningType, "Please don't run minikube as root or with 'sudo' privileges. It isn't necessary.") } } diff --git a/pkg/minikube/cluster/cluster.go b/pkg/minikube/cluster/cluster.go index 7642204d13..f1b91d5d12 100644 --- a/pkg/minikube/cluster/cluster.go +++ b/pkg/minikube/cluster/cluster.go @@ -254,7 +254,7 @@ func DeleteHost(api libmachine.API) error { return errors.Wrap(err, "load") } // This is slow if SSH is not responding, but HyperV hangs otherwise, See issue #2914 - if host.Driver.DriverName() == "hyperv" { + if host.Driver.DriverName() == constants.DriverHyperv { trySSHPowerOff(host) } @@ -320,21 +320,21 @@ func engineOptions(config cfg.MachineConfig) *engine.Options { func preCreateHost(config *cfg.MachineConfig) { switch config.VMDriver { - case "kvm": + case constants.DriverKvmOld: if viper.GetBool(cfg.ShowDriverDeprecationNotification) { console.Warning(`The kvm driver is deprecated and support for it will be removed in a future release. Please consider switching to the kvm2 driver, which is intended to replace the kvm driver. See https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#kvm2-driver for more information. To disable this message, run [minikube config set ShowDriverDeprecationNotification false]`) } - case "xhyve": + case constants.DriverXhyve: if viper.GetBool(cfg.ShowDriverDeprecationNotification) { console.Warning(`The xhyve driver is deprecated and support for it will be removed in a future release. Please consider switching to the hyperkit driver, which is intended to replace the xhyve driver. See https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#hyperkit-driver for more information. To disable this message, run [minikube config set ShowDriverDeprecationNotification false]`) } - case "vmwarefusion": + case constants.DriverVmwareFusion: if viper.GetBool(cfg.ShowDriverDeprecationNotification) { console.Warning(`The vmwarefusion driver is deprecated and support for it will be removed in a future release. Please consider switching to the new vmware unified driver, which is intended to replace the vmwarefusion driver. @@ -407,11 +407,11 @@ func GetHostDockerEnv(api libmachine.API) (map[string]string, error) { // GetVMHostIP gets the ip address to be used for mapping host -> VM and VM -> host func GetVMHostIP(host *host.Host) (net.IP, error) { switch host.DriverName { - case "kvm": + case constants.DriverKvmOld: return net.ParseIP("192.168.42.1"), nil case constants.DriverKvm2: return net.ParseIP("192.168.39.1"), nil - case "hyperv": + case constants.DriverHyperv: re := regexp.MustCompile(`"VSwitch": "(.*?)",`) // TODO(aprindle) Change this to deserialize the driver instead hypervVirtualSwitch := re.FindStringSubmatch(string(host.RawDriver))[1] @@ -432,7 +432,7 @@ func GetVMHostIP(host *host.Host) (net.IP, error) { return []byte{}, errors.Wrap(err, "Error getting VM/Host IP address") } return ip, nil - case "xhyve", constants.DriverHyperkit: + case constants.DriverXhyve, constants.DriverHyperkit: return net.ParseIP("192.168.64.1"), nil case constants.DriverVmware: vmIPString, err := host.Driver.GetIP() diff --git a/pkg/minikube/config/config_test.go b/pkg/minikube/config/config_test.go index 3a563e9235..ecc13c5ce7 100644 --- a/pkg/minikube/config/config_test.go +++ b/pkg/minikube/config/config_test.go @@ -20,6 +20,8 @@ import ( "bytes" "reflect" "testing" + + "k8s.io/minikube/pkg/minikube/constants" ) type configTestCase struct { @@ -47,7 +49,7 @@ var configTestCases = []configTestCase{ "vm-driver": "kvm" }`, config: map[string]interface{}{ - "vm-driver": "kvm", + "vm-driver": constants.DriverKvmOld, "cpus": 4, "disk-size": "20g", "v": 5, diff --git a/pkg/minikube/constants/constants.go b/pkg/minikube/constants/constants.go index a01ab32af2..698a3abc59 100644 --- a/pkg/minikube/constants/constants.go +++ b/pkg/minikube/constants/constants.go @@ -62,30 +62,42 @@ func ArchTag(hasTag bool) string { // DriverNone is the none driver. const DriverNone = "none" -// DriverKvmOld is the old kvm driver option +// DriverKvmOld is the depricated kvm driver option name const DriverKvmOld = "kvm" -// DriverKvm2 is the kvm2 driver option used in linux +// DriverKvm2 is the kvm2 driver option name for in linux const DriverKvm2 = "kvm2" -// DriverVirtualbox is the virtualbox driver option +// DriverVirtualbox is the virtualbox driver option name const DriverVirtualbox = "virtualbox" -// DriverHyperkit is the hyperkit driver option for mac os +// DriverHyperkit is the hyperkit driver option name for mac os const DriverHyperkit = "hyperkit" -// DriverVmware is the hyperkit driver option for mac os +// DriverVmware is the vmware driver option name const DriverVmware = "vmware" +// DriverVmwareFusion is the vmware fusion driver option +const DriverVmwareFusion = "vmwarefusion" + +// DriverHyperv is the hyperv driver option for windows +const DriverHyperv = "hyperv" + +// DriverXhyve is the depricated xhyve driver option name +const DriverXhyve = "xhyve" + +// DriverParallels is the parallels driver option name +const DriverParallels = "parallels" + // SupportedVMDrivers is a list of supported drivers on all platforms. Currently // used in gendocs. var SupportedVMDrivers = [...]string{ DriverVirtualbox, - "parallels", - "vmwarefusion", + DriverParallels, + DriverVmwareFusion, DriverKvmOld, - "xhyve", - "hyperv", + DriverXhyve, + DriverHyperv, DriverHyperkit, DriverKvm2, DriverVmware, diff --git a/pkg/minikube/drivers/hyperv/driver.go b/pkg/minikube/drivers/hyperv/driver.go index 58d3eac839..11ef8fa51b 100644 --- a/pkg/minikube/drivers/hyperv/driver.go +++ b/pkg/minikube/drivers/hyperv/driver.go @@ -28,7 +28,7 @@ import ( func init() { registry.Register(registry.DriverDef{ - Name: "hyperv", + Name: constants.DriverHyperv, Builtin: true, ConfigCreator: createHypervHost, DriverCreator: func() drivers.Driver { diff --git a/pkg/minikube/drivers/kvm/driver.go b/pkg/minikube/drivers/kvm/driver.go index a35d2a5aee..989e74276f 100644 --- a/pkg/minikube/drivers/kvm/driver.go +++ b/pkg/minikube/drivers/kvm/driver.go @@ -30,7 +30,7 @@ import ( func init() { if err := registry.Register(registry.DriverDef{ - Name: "kvm", + Name: constants.DriverKvmOld, Builtin: false, ConfigCreator: createKVMHost, }); err != nil { diff --git a/pkg/minikube/drivers/parallels/driver.go b/pkg/minikube/drivers/parallels/driver.go index 7921bb1f80..b452dd6781 100644 --- a/pkg/minikube/drivers/parallels/driver.go +++ b/pkg/minikube/drivers/parallels/driver.go @@ -30,7 +30,7 @@ import ( func init() { err := registry.Register(registry.DriverDef{ - Name: "parallels", + Name: constants.DriverParallels, Builtin: true, ConfigCreator: createParallelsHost, DriverCreator: func() drivers.Driver { diff --git a/pkg/minikube/drivers/vmwarefusion/driver.go b/pkg/minikube/drivers/vmwarefusion/driver.go index ce82041be6..07e77bbe3c 100644 --- a/pkg/minikube/drivers/vmwarefusion/driver.go +++ b/pkg/minikube/drivers/vmwarefusion/driver.go @@ -30,7 +30,7 @@ import ( func init() { if err := registry.Register(registry.DriverDef{ - Name: "vmwarefusion", + Name: constants.DriverVmwareFusion, Builtin: true, ConfigCreator: createVMwareFusionHost, DriverCreator: func() drivers.Driver { diff --git a/pkg/minikube/drivers/xhyve/driver.go b/pkg/minikube/drivers/xhyve/driver.go index 89559f313c..3fc0ae21fb 100644 --- a/pkg/minikube/drivers/xhyve/driver.go +++ b/pkg/minikube/drivers/xhyve/driver.go @@ -35,7 +35,7 @@ https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#xhyve-driver func init() { if err := registry.Register(registry.DriverDef{ - Name: "xhyve", + Name: constants.DriverXhyve, Builtin: false, ConfigCreator: createXhyveHost, DriverCreator: func() drivers.Driver {