Improve typecheck for driver options
parent
c7bf1ce7cd
commit
34fda98f4e
|
@ -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,
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
)
|
||||
|
||||
var minikubeConfig = pkgConfig.MinikubeConfig{
|
||||
"vm-driver": "kvm",
|
||||
"vm-driver": constants.DriverKvmOld,
|
||||
"cpus": 12,
|
||||
"show-libmachine-logs": true,
|
||||
}
|
||||
|
|
|
@ -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.")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
|
||||
func init() {
|
||||
registry.Register(registry.DriverDef{
|
||||
Name: "hyperv",
|
||||
Name: constants.DriverHyperv,
|
||||
Builtin: true,
|
||||
ConfigCreator: createHypervHost,
|
||||
DriverCreator: func() drivers.Driver {
|
||||
|
|
|
@ -30,7 +30,7 @@ import (
|
|||
|
||||
func init() {
|
||||
if err := registry.Register(registry.DriverDef{
|
||||
Name: "kvm",
|
||||
Name: constants.DriverKvmOld,
|
||||
Builtin: false,
|
||||
ConfigCreator: createKVMHost,
|
||||
}); err != nil {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue