Skip to content

Commit 1b5f71c

Browse files
committed
Minikube start respects MINIKUBE_ prefixed env now
1 parent bcf3597 commit 1b5f71c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

cmd/minikube/cmd/start.go

+25
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,19 @@ func init() {
128128

129129
// initMinikubeFlags includes commandline flags for minikube.
130130
func initMinikubeFlags() {
131+
viper.SetEnvPrefix(constants.MinikubeEnvPrefix)
132+
// Replaces '-' in flags with '_' in env variables
133+
// e.g. iso-url => $ENVPREFIX_ISO_URL
134+
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
135+
viper.AutomaticEnv()
136+
137+
startCmd.Flags().Bool(keepContext, constants.DefaultKeepContext, "This will keep the existing kubectl context and will create a minikube context.")
138+
startCmd.Flags().Bool(createMount, false, "This will start the mount daemon and automatically mount files into minikube")
139+
startCmd.Flags().String(mountString, constants.DefaultMountDir+":"+constants.DefaultMountEndpoint, "The argument to pass the minikube mount command on start")
140+
startCmd.Flags().Bool(disableDriverMounts, false, "Disables the filesystem mounts provided by the hypervisors (vboxfs, xhyve-9p)")
141+
startCmd.Flags().String(isoURL, constants.DefaultISOURL, "Location of the minikube iso")
142+
startCmd.Flags().String(vmDriver, constants.DefaultVMDriver, fmt.Sprintf("VM driver is one of: %v", constants.SupportedVMDrivers))
143+
startCmd.Flags().Int(memory, constants.DefaultMemory, "Amount of RAM allocated to the minikube VM in MB")
131144
startCmd.Flags().Int(cpus, constants.DefaultCPUS, "Number of CPUs allocated to the minikube VM")
132145
startCmd.Flags().String(memory, constants.DefaultMemorySize, "Amount of RAM allocated to the minikube VM (format: <number>[<unit>], where unit = b, k, m or g)")
133146
startCmd.Flags().String(humanReadableDiskSize, constants.DefaultDiskSize, "Disk size allocated to the minikube VM (format: <number>[<unit>], where unit = b, k, m or g)")
@@ -210,6 +223,18 @@ var startCmd = &cobra.Command{
210223
// runStart handles the executes the flow of "minikube start"
211224
func runStart(cmd *cobra.Command, args []string) {
212225
out.T(out.Happy, "minikube {{.version}} on {{.os}} ({{.arch}})", out.V{"version": version.GetVersion(), "os": runtime.GOOS, "arch": runtime.GOARCH})
226+
227+
// if --registry-mirror specified when run minikube start,
228+
// take arg precedence over MINIKUBE_REGISTRY_MIRROR
229+
// actually this is a hack, because viper 1.0.0 can assign env to variable if StringSliceVar
230+
// and i can't update it to 1.4.0, it affects too much code
231+
// other types (like String, Bool) of flag works, so imageRepository, imageMirrorCountry
232+
// can be configured as MINIKUBE_IMAGE_REPOSITORY and IMAGE_MIRROR_COUNTRY
233+
// this should be updated to documentation
234+
if len(registryMirror) == 0 {
235+
registryMirror = viper.GetStringSlice("registry_mirror")
236+
}
237+
213238
validateConfig()
214239
validateUser()
215240

0 commit comments

Comments
 (0)