Skip to content

Commit

Permalink
Merge pull request #11469 from utkarsh-pro/utkarsh-pro/fix/11171
Browse files Browse the repository at this point in the history
Support setting addons from environmental variables
  • Loading branch information
medyagh committed May 26, 2021
2 parents 791c941 + aa99526 commit b1ce37b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 3 additions & 1 deletion pkg/addons/validations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkg/minikube/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b1ce37b

Please sign in to comment.