diff --git a/cmd/minikube/cmd/start_flags.go b/cmd/minikube/cmd/start_flags.go index 4bed46dc260c..770d605cca88 100644 --- a/cmd/minikube/cmd/start_flags.go +++ b/cmd/minikube/cmd/start_flags.go @@ -147,7 +147,7 @@ func initMinikubeFlags() { startCmd.Flags().String(containerRuntime, constants.DefaultContainerRuntime, fmt.Sprintf("The container runtime to be used (%s).", strings.Join(cruntime.ValidRuntimes(), ", "))) startCmd.Flags().Bool(createMount, false, "This will start the mount daemon and automatically mount files into minikube.") startCmd.Flags().String(mountString, constants.DefaultMountDir+":/minikube-host", "The argument to pass the minikube mount command on start.") - startCmd.Flags().StringSliceVar(&config.AddonList, "addons", nil, "Enable addons. see `minikube addons list` for a list of valid addon names.") + startCmd.Flags().StringSlice(config.AddonListFlag, nil, "Enable addons. see `minikube addons list` for a list of valid addon names.") startCmd.Flags().String(criSocket, "", "The cri socket path to be used.") startCmd.Flags().String(networkPlugin, "", "Kubelet network plug-in to use (default: auto)") startCmd.Flags().Bool(enableDefaultCNI, false, "DEPRECATED: Replaced by --cni=bridge") diff --git a/pkg/addons/validations.go b/pkg/addons/validations.go index aad44e3cf05e..9cefbe321f3a 100644 --- a/pkg/addons/validations.go +++ b/pkg/addons/validations.go @@ -20,6 +20,7 @@ import ( "fmt" "strconv" + "github.com/spf13/viper" "k8s.io/minikube/pkg/minikube/assets" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/cruntime" @@ -63,7 +64,8 @@ func IsVolumesnapshotsEnabled(cc *config.ClusterConfig, _, value string) error { isCsiDriverEnabled, _ := strconv.ParseBool(value) // assets.Addons[].IsEnabled() returns the current status of the addon or default value. // config.AddonList contains list of addons to be enabled. - isVolumesnapshotsEnabled := assets.Addons[volumesnapshotsAddon].IsEnabled(cc) || contains(config.AddonList, volumesnapshotsAddon) + addonList := viper.GetStringSlice(config.AddonListFlag) + isVolumesnapshotsEnabled := assets.Addons[volumesnapshotsAddon].IsEnabled(cc) || contains(addonList, volumesnapshotsAddon) if isCsiDriverEnabled && !isVolumesnapshotsEnabled { // just print out a warning directly, we don't want to return any errors since // that would prevent the addon from being enabled (callbacks wouldn't be run) diff --git a/pkg/minikube/config/config.go b/pkg/minikube/config/config.go index c359087740ce..f194099266a5 100644 --- a/pkg/minikube/config/config.go +++ b/pkg/minikube/config/config.go @@ -56,6 +56,8 @@ const ( AddonImages = "addon-images" // AddonRegistries stores custom addon images config AddonRegistries = "addon-registries" + // AddonListFlag represents the key for addons parameter + AddonListFlag = "addons" ) var ( @@ -67,8 +69,6 @@ var ( DockerOpt []string // ExtraOptions contains extra options (if any) ExtraOptions ExtraOptionSlice - // AddonList contains the list of addons - AddonList []string ) // ErrNotExist is the error returned when a config does not exist diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 7a9f1e304fcc..9e3f59e9ede6 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -171,12 +171,13 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) { }() // enable addons, both old and new! + addonList := viper.GetStringSlice(config.AddonListFlag) if starter.ExistingAddons != nil { if viper.GetBool("force") { addons.Force = true } wg.Add(1) - go addons.Start(&wg, starter.Cfg, starter.ExistingAddons, config.AddonList) + go addons.Start(&wg, starter.Cfg, starter.ExistingAddons, addonList) } if apiServer {