changing string driver name to checked type

pull/4419/head
Medya Gh 2019-06-03 20:27:26 -07:00
parent 6aa51c1abb
commit 6d57b28fdd
8 changed files with 13 additions and 10 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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{

View File

@ -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")}
}

View File

@ -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 {

View File

@ -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)