Skip to content

Commit 2806396

Browse files
Merge pull request #4419 from medyagh/none_struct
Improve type check for driver none
2 parents d556d58 + 7c8a0e2 commit 2806396

File tree

8 files changed

+13
-10
lines changed

8 files changed

+13
-10
lines changed

Diff for: cmd/minikube/cmd/delete.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ associated files.`,
5656
}
5757

5858
// In the case of "none", we want to uninstall Kubernetes as there is no VM to delete
59-
if err == nil && cc.MachineConfig.VMDriver == "none" {
59+
if err == nil && cc.MachineConfig.VMDriver == constants.DriverNone {
6060
kc := cc.KubernetesConfig
6161
bsName := viper.GetString(cmdcfg.Bootstrapper)
6262
console.OutStyle(console.Resetting, "Uninstalling Kubernetes %s using %s ...", kc.KubernetesVersion, bsName)

Diff for: cmd/minikube/cmd/env.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/spf13/cobra"
3636
"k8s.io/minikube/pkg/minikube/cluster"
3737
"k8s.io/minikube/pkg/minikube/config"
38+
"k8s.io/minikube/pkg/minikube/constants"
3839
"k8s.io/minikube/pkg/minikube/exit"
3940
"k8s.io/minikube/pkg/minikube/machine"
4041
)
@@ -342,7 +343,7 @@ var dockerEnvCmd = &cobra.Command{
342343
if err != nil {
343344
exit.WithError("Error getting host", err)
344345
}
345-
if host.Driver.DriverName() == "none" {
346+
if host.Driver.DriverName() == constants.DriverNone {
346347
exit.Usage(`'none' driver does not support 'minikube docker-env' command`)
347348
}
348349
hostSt, err := cluster.GetHostStatus(api)

Diff for: cmd/minikube/cmd/mount.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ var mountCmd = &cobra.Command{
102102
if err != nil {
103103
exit.WithError("Error loading api", err)
104104
}
105-
if host.Driver.DriverName() == "none" {
105+
if host.Driver.DriverName() == constants.DriverNone {
106106
exit.Usage(`'none' driver does not support 'minikube mount' command`)
107107
}
108108
var ip net.IP

Diff for: cmd/minikube/cmd/ssh.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"k8s.io/minikube/pkg/minikube/cluster"
2424
"k8s.io/minikube/pkg/minikube/config"
2525
"k8s.io/minikube/pkg/minikube/console"
26+
"k8s.io/minikube/pkg/minikube/constants"
2627
"k8s.io/minikube/pkg/minikube/exit"
2728
"k8s.io/minikube/pkg/minikube/machine"
2829
)
@@ -42,7 +43,7 @@ var sshCmd = &cobra.Command{
4243
if err != nil {
4344
exit.WithError("Error getting host", err)
4445
}
45-
if host.Driver.DriverName() == "none" {
46+
if host.Driver.DriverName() == constants.DriverNone {
4647
exit.Usage("'none' driver does not support 'minikube ssh' command")
4748
}
4849
err = cluster.CreateSSHShell(api, args)

Diff for: pkg/drivers/none/none.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ import (
2727
"k8s.io/apimachinery/pkg/util/net"
2828
pkgdrivers "k8s.io/minikube/pkg/drivers" // TODO(tstromberg): Extract CommandRunner into its own package
2929
"k8s.io/minikube/pkg/minikube/bootstrapper"
30+
"k8s.io/minikube/pkg/minikube/constants"
3031
"k8s.io/minikube/pkg/minikube/cruntime"
3132
)
3233

33-
const driverName = "none"
34+
const driverName = constants.DriverNone
3435

3536
// cleanupPaths are paths to be removed by cleanup, and are used by both kubeadm and minikube.
3637
var cleanupPaths = []string{

Diff for: pkg/minikube/cluster/cluster.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func init() {
7272

7373
// CacheISO downloads and caches ISO.
7474
func CacheISO(config cfg.MachineConfig) error {
75-
if config.VMDriver != "none" {
75+
if config.VMDriver != constants.DriverNone {
7676
if err := config.Downloader.CacheMinikubeISOFromURL(config.MinikubeISO); err != nil {
7777
return err
7878
}
@@ -154,7 +154,7 @@ func configureHost(h *host.Host, e *engine.Options) error {
154154
}
155155
}
156156

157-
if h.Driver.DriverName() != "none" {
157+
if h.Driver.DriverName() != constants.DriverNone {
158158
if err := h.ConfigureAuth(); err != nil {
159159
return &util.RetriableError{Err: errors.Wrap(err, "Error configuring auth on host")}
160160
}

Diff for: pkg/minikube/drivers/none/driver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828

2929
func init() {
3030
if err := registry.Register(registry.DriverDef{
31-
Name: "none",
31+
Name: constants.DriverNone,
3232
Builtin: true,
3333
ConfigCreator: createNoneHost,
3434
DriverCreator: func() drivers.Driver {

Diff for: pkg/minikube/machine/client.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func (api *LocalClient) Create(h *host.Host) error {
189189
{
190190
"waiting",
191191
func() error {
192-
if h.Driver.DriverName() == "none" {
192+
if h.Driver.DriverName() == constants.DriverNone {
193193
return nil
194194
}
195195
return mcnutils.WaitFor(drivers.MachineInState(h.Driver, state.Running))
@@ -198,7 +198,7 @@ func (api *LocalClient) Create(h *host.Host) error {
198198
{
199199
"provisioning",
200200
func() error {
201-
if h.Driver.DriverName() == "none" {
201+
if h.Driver.DriverName() == constants.DriverNone {
202202
return nil
203203
}
204204
pv := provision.NewBuildrootProvisioner(h.Driver)

0 commit comments

Comments
 (0)