Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve type check for driver none #4419

Merged
merged 3 commits into from
Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion cmd/minikube/cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion cmd/minikube/cmd/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion pkg/drivers/none/none.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func init() {

// CacheISO downloads and caches ISO.
func CacheISO(config cfg.MachineConfig) error {
if config.VMDriver != "none" {
if config.VMDriver == constants.DriverNone {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic looks like it has been reversed ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooops good catch. thanks for catching it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if err := config.Downloader.CacheMinikubeISOFromURL(config.MinikubeISO); err != nil {
return err
}
Expand Down Expand Up @@ -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")}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/drivers/none/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/machine/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand Down