Skip to content

Commit b1ce37b

Browse files
authored
Merge pull request #11469 from utkarsh-pro/utkarsh-pro/fix/11171
Support setting addons from environmental variables
2 parents 791c941 + aa99526 commit b1ce37b

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

cmd/minikube/cmd/start_flags.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func initMinikubeFlags() {
147147
startCmd.Flags().String(containerRuntime, constants.DefaultContainerRuntime, fmt.Sprintf("The container runtime to be used (%s).", strings.Join(cruntime.ValidRuntimes(), ", ")))
148148
startCmd.Flags().Bool(createMount, false, "This will start the mount daemon and automatically mount files into minikube.")
149149
startCmd.Flags().String(mountString, constants.DefaultMountDir+":/minikube-host", "The argument to pass the minikube mount command on start.")
150-
startCmd.Flags().StringSliceVar(&config.AddonList, "addons", nil, "Enable addons. see `minikube addons list` for a list of valid addon names.")
150+
startCmd.Flags().StringSlice(config.AddonListFlag, nil, "Enable addons. see `minikube addons list` for a list of valid addon names.")
151151
startCmd.Flags().String(criSocket, "", "The cri socket path to be used.")
152152
startCmd.Flags().String(networkPlugin, "", "Kubelet network plug-in to use (default: auto)")
153153
startCmd.Flags().Bool(enableDefaultCNI, false, "DEPRECATED: Replaced by --cni=bridge")

pkg/addons/validations.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"strconv"
2222

23+
"github.com/spf13/viper"
2324
"k8s.io/minikube/pkg/minikube/assets"
2425
"k8s.io/minikube/pkg/minikube/config"
2526
"k8s.io/minikube/pkg/minikube/cruntime"
@@ -63,7 +64,8 @@ func IsVolumesnapshotsEnabled(cc *config.ClusterConfig, _, value string) error {
6364
isCsiDriverEnabled, _ := strconv.ParseBool(value)
6465
// assets.Addons[].IsEnabled() returns the current status of the addon or default value.
6566
// config.AddonList contains list of addons to be enabled.
66-
isVolumesnapshotsEnabled := assets.Addons[volumesnapshotsAddon].IsEnabled(cc) || contains(config.AddonList, volumesnapshotsAddon)
67+
addonList := viper.GetStringSlice(config.AddonListFlag)
68+
isVolumesnapshotsEnabled := assets.Addons[volumesnapshotsAddon].IsEnabled(cc) || contains(addonList, volumesnapshotsAddon)
6769
if isCsiDriverEnabled && !isVolumesnapshotsEnabled {
6870
// just print out a warning directly, we don't want to return any errors since
6971
// that would prevent the addon from being enabled (callbacks wouldn't be run)

pkg/minikube/config/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ const (
5656
AddonImages = "addon-images"
5757
// AddonRegistries stores custom addon images config
5858
AddonRegistries = "addon-registries"
59+
// AddonListFlag represents the key for addons parameter
60+
AddonListFlag = "addons"
5961
)
6062

6163
var (
@@ -67,8 +69,6 @@ var (
6769
DockerOpt []string
6870
// ExtraOptions contains extra options (if any)
6971
ExtraOptions ExtraOptionSlice
70-
// AddonList contains the list of addons
71-
AddonList []string
7272
)
7373

7474
// ErrNotExist is the error returned when a config does not exist

pkg/minikube/node/start.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,13 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) {
171171
}()
172172

173173
// enable addons, both old and new!
174+
addonList := viper.GetStringSlice(config.AddonListFlag)
174175
if starter.ExistingAddons != nil {
175176
if viper.GetBool("force") {
176177
addons.Force = true
177178
}
178179
wg.Add(1)
179-
go addons.Start(&wg, starter.Cfg, starter.ExistingAddons, config.AddonList)
180+
go addons.Start(&wg, starter.Cfg, starter.ExistingAddons, addonList)
180181
}
181182

182183
if apiServer {

0 commit comments

Comments
 (0)