@@ -173,8 +173,8 @@ func initMinikubeFlags() {
173173 startCmd .Flags ().Bool (keepContext , false , "This will keep the existing kubectl context and will create a minikube context." )
174174 startCmd .Flags ().Bool (embedCerts , false , "if true, will embed the certs in kubeconfig." )
175175 startCmd .Flags ().StringP (containerRuntime , "c" , constants .DefaultContainerRuntime , fmt .Sprintf ("The container runtime to be used. Valid options: %s (default: auto)" , strings .Join (cruntime .ValidRuntimes (), ", " )))
176- startCmd .Flags ().Bool (createMount , false , "Kept for backward compatibility, value is ignored." )
177- startCmd .Flags ().String (mountString , "" , "Directory to mount in the guest using format '/host-path:/guest-path'. " )
176+ startCmd .Flags ().String (createMount , "" , "Kept for backward compatibility, value is ignored." )
177+ startCmd .Flags ().String (mountString , "" , "DEPRECATED: specify mount path in old style " )
178178 startCmd .Flags ().String (mount9PVersion , defaultMount9PVersion , mount9PVersionDescription )
179179 startCmd .Flags ().String (mountGID , defaultMountGID , mountGIDDescription )
180180 startCmd .Flags ().String (mountIPFlag , defaultMountIP , mountIPDescription )
@@ -655,7 +655,7 @@ func generateNewConfigFromFlags(cmd *cobra.Command, k8sVersion string, rtime str
655655 }
656656 cc .VerifyComponents = interpretWaitFlag (* cmd )
657657
658- if viper . GetString ( mountString ) != "" && driver .IsKIC (drvName ) {
658+ if cmd . Flags (). Changed ( createMount ) && driver .IsKIC (drvName ) {
659659 cc .ContainerVolumeMounts = []string {viper .GetString (mountString )}
660660 }
661661
@@ -922,6 +922,11 @@ func updateExistingConfigFromFlags(cmd *cobra.Command, existing *config.ClusterC
922922 cc .ScheduledStop = nil
923923 }
924924
925+ if cmd .Flags ().Changed (createMount ) || cmd .Flags ().Changed (mountString ) {
926+ cc .Mount , cc .MountString = interpretMountFlag (cmd )
927+ klog .Infof ("Parsed mount flags => Mount: %v, MountString: %q" , cc .Mount , cc .MountString )
928+ }
929+
925930 return cc
926931}
927932
@@ -1012,6 +1017,39 @@ func interpretWaitFlag(cmd cobra.Command) map[string]bool {
10121017 return waitComponents
10131018}
10141019
1020+ func interpretMountFlag (cmd * cobra.Command ) (bool , string ) {
1021+ mountBool := false
1022+ mountPath := ""
1023+
1024+ mountVal , _ := cmd .Flags ().GetString (createMount )
1025+ mountStringFlag , _ := cmd .Flags ().GetString (mountString )
1026+
1027+ if mountVal == "" && mountStringFlag == "" {
1028+ klog .Infof ("No mount flag provided. Mount disabled by default." )
1029+ return false , ""
1030+ }
1031+
1032+ // parse mount flag
1033+ if mountVal == "true" {
1034+ mountBool = true
1035+ } else if mountVal == "false" || mountVal == "none" {
1036+ mountBool = false
1037+ } else if mountVal != "" {
1038+ // mount=/host:/guest
1039+ mountBool = true
1040+ mountPath = mountVal
1041+ }
1042+
1043+ // mount-string flag takes precedence over create-mount flag
1044+ if mountStringFlag != "" {
1045+ mountBool = true
1046+ mountPath = mountStringFlag
1047+ }
1048+
1049+ klog .Infof ("Mount enabled: %v, Mount path: %q" , mountBool , mountPath )
1050+ return mountBool , mountPath
1051+ }
1052+
10151053func checkExtraDiskOptions (cmd * cobra.Command , driverName string ) {
10161054 supportedDrivers := []string {driver .HyperKit , driver .KVM2 , driver .QEMU2 , driver .VFKit , driver .Krunkit }
10171055
0 commit comments