@@ -27,6 +27,7 @@ import (
2727
2828 "github.com/spf13/cobra"
2929 "k8s.io/klog/v2"
30+ "k8s.io/minikube/cmd/minikube/cmd/flags"
3031 "k8s.io/minikube/pkg/addons"
3132 "k8s.io/minikube/pkg/minikube/assets"
3233 "k8s.io/minikube/pkg/minikube/cluster"
@@ -37,6 +38,7 @@ import (
3738 "k8s.io/minikube/pkg/minikube/mustload"
3839 "k8s.io/minikube/pkg/minikube/out"
3940 "k8s.io/minikube/pkg/minikube/reason"
41+ "k8s.io/minikube/pkg/minikube/run"
4042 "k8s.io/minikube/pkg/minikube/style"
4143 "k8s.io/minikube/pkg/minikube/sysinit"
4244)
@@ -59,6 +61,7 @@ var addonsConfigureCmd = &cobra.Command{
5961 exit .Message (reason .Usage , "usage: minikube addons configure ADDON_NAME" )
6062 }
6163
64+ options := flags .CommandOptions ()
6265 profile := ClusterFlagValue ()
6366 addon := args [0 ]
6467 addonConfig := loadAddonConfigFile (addon , addonConfigFile )
@@ -69,16 +72,16 @@ var addonsConfigureCmd = &cobra.Command{
6972 processRegistryCredsConfig (profile , addonConfig )
7073
7174 case "metallb" :
72- processMetalLBConfig (profile , addonConfig )
75+ processMetalLBConfig (profile , addonConfig , options )
7376
7477 case "ingress" :
75- processIngressConfig (profile , addonConfig )
78+ processIngressConfig (profile , addonConfig , options )
7679
7780 case "registry-aliases" :
78- processRegistryAliasesConfig (profile , addonConfig )
81+ processRegistryAliasesConfig (profile , addonConfig , options )
7982
8083 case "auto-pause" :
81- processAutoPauseConfig (profile , addonConfig )
84+ processAutoPauseConfig (profile , addonConfig , options )
8285
8386 default :
8487 out .FailureT ("{{.name}} has no available configuration options" , out.V {"name" : addon })
@@ -162,8 +165,8 @@ func loadAddonConfigFile(addon, configFilePath string) (ac *addonConfig) {
162165}
163166
164167// Processes metallb addon config from configFile if it exists otherwise resorts to default behavior
165- func processMetalLBConfig (profile string , _ * addonConfig ) {
166- _ , cfg := mustload .Partial (profile )
168+ func processMetalLBConfig (profile string , _ * addonConfig , options * run. CommandOptions ) {
169+ _ , cfg := mustload .Partial (profile , options )
167170
168171 validator := func (s string ) bool {
169172 return net .ParseIP (s ) != nil
@@ -178,14 +181,14 @@ func processMetalLBConfig(profile string, _ *addonConfig) {
178181 }
179182
180183 // Re-enable metallb addon in order to generate template manifest files with Load Balancer Start/End IP
181- if err := addons .EnableOrDisableAddon (cfg , "metallb" , "true" ); err != nil {
184+ if err := addons .EnableOrDisableAddon (cfg , "metallb" , "true" , options ); err != nil {
182185 out .ErrT (style .Fatal , "Failed to configure metallb IP {{.profile}}" , out.V {"profile" : profile })
183186 }
184187}
185188
186189// Processes ingress addon config from configFile if it exists otherwise resorts to default behavior
187- func processIngressConfig (profile string , _ * addonConfig ) {
188- _ , cfg := mustload .Partial (profile )
190+ func processIngressConfig (profile string , _ * addonConfig , options * run. CommandOptions ) {
191+ _ , cfg := mustload .Partial (profile , options )
189192
190193 validator := func (s string ) bool {
191194 format := regexp .MustCompile ("^.+/.+$" )
@@ -208,8 +211,8 @@ func processIngressConfig(profile string, _ *addonConfig) {
208211}
209212
210213// Processes auto-pause addon config from configFile if it exists otherwise resorts to default behavior
211- func processAutoPauseConfig (profile string , _ * addonConfig ) {
212- lapi , cfg := mustload .Partial (profile )
214+ func processAutoPauseConfig (profile string , _ * addonConfig , options * run. CommandOptions ) {
215+ lapi , cfg := mustload .Partial (profile , options )
213216 intervalInput := AskForStaticValue ("-- Enter interval time of auto-pause-interval (ex. 1m0s): " )
214217 intervalTime , err := time .ParseDuration (intervalInput )
215218 if err != nil {
@@ -234,11 +237,11 @@ func processAutoPauseConfig(profile string, _ *addonConfig) {
234237 out .ErrT (style .Fatal , "failed to load profile: {{.error}}" , out.V {"error" : err })
235238 }
236239 if profileStatus (p , lapi ).StatusCode / 100 == 2 { // 2xx code
237- co := mustload .Running (profile )
240+ co := mustload .Running (profile , options )
238241 // first unpause all nodes cluster immediately
239242 unpauseWholeCluster (co )
240243 // Re-enable auto-pause addon in order to update interval time
241- if err := addons .EnableOrDisableAddon (cfg , "auto-pause" , "true" ); err != nil {
244+ if err := addons .EnableOrDisableAddon (cfg , "auto-pause" , "true" , options ); err != nil {
242245 out .ErrT (style .Fatal , "Failed to configure auto-pause {{.profile}}" , out.V {"profile" : profile })
243246 }
244247 // restart auto-pause service
@@ -250,8 +253,8 @@ func processAutoPauseConfig(profile string, _ *addonConfig) {
250253}
251254
252255// Processes registry-aliases addon config from configFile if it exists otherwise resorts to default behavior
253- func processRegistryAliasesConfig (profile string , _ * addonConfig ) {
254- _ , cfg := mustload .Partial (profile )
256+ func processRegistryAliasesConfig (profile string , _ * addonConfig , options * run. CommandOptions ) {
257+ _ , cfg := mustload .Partial (profile , options )
255258 validator := func (s string ) bool {
256259 format := regexp .MustCompile (`^([a-zA-Z0-9-_]+\.[a-zA-Z0-9-_]+)+(\ [a-zA-Z0-9-_]+\.[a-zA-Z0-9-_]+)*$` )
257260 return format .MatchString (s )
@@ -266,7 +269,7 @@ func processRegistryAliasesConfig(profile string, _ *addonConfig) {
266269 addon := assets .Addons ["registry-aliases" ]
267270 if addon .IsEnabled (cfg ) {
268271 // Re-enable registry-aliases addon in order to generate template manifest files with custom hosts
269- if err := addons .EnableOrDisableAddon (cfg , "registry-aliases" , "true" ); err != nil {
272+ if err := addons .EnableOrDisableAddon (cfg , "registry-aliases" , "true" , options ); err != nil {
270273 out .ErrT (style .Fatal , "Failed to configure registry-aliases {{.profile}}" , out.V {"profile" : profile })
271274 }
272275 }
0 commit comments