replace addonList variable with viper provided data

Signed-off-by: Utkarsh Srivastava <srivastavautkarsh8097@gmail.com>
pull/11469/head
Utkarsh Srivastava 2021-05-20 21:39:07 +05:30
parent 316f5ea3b2
commit 5a3843b074
No known key found for this signature in database
GPG Key ID: 2079F77E863230BF
4 changed files with 8 additions and 5 deletions

View File

@ -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.AddonListName, 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")

View File

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

View File

@ -56,6 +56,8 @@ const (
AddonImages = "addon-images"
// AddonRegistries stores custom addon images config
AddonRegistries = "addon-registries"
// AddonListName represents the key for addons parameter
AddonListName = "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

View File

@ -171,12 +171,13 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) {
}()
// enable addons, both old and new!
addonList := viper.GetStringSlice(config.AddonListName)
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 {