@@ -294,6 +294,7 @@ func runStart(cmd *cobra.Command, args []string) {
294
294
exit .WithCodeT (exit .Data , "Unable to load config: {{.error}}" , out.V {"error" : err })
295
295
}
296
296
297
+ validateSpecifiedDriver (existing )
297
298
ds := selectDriver (existing )
298
299
driverName := ds .Name
299
300
glog .Infof ("selected driver: %s" , driverName )
@@ -482,36 +483,20 @@ func selectDriver(existing *config.ClusterConfig) registry.DriverState {
482
483
return pick
483
484
}
484
485
485
- // validateDriver validates that the selected driver appears sane, exits if not
486
- func validateDriver (ds registry.DriverState , existing * config.ClusterConfig ) {
487
- name := ds .Name
488
- glog .Infof ("validating driver %q against %+v" , name , existing )
489
- if ! driver .Supported (name ) {
490
- exit .WithCodeT (exit .Unavailable , "The driver {{.experimental}} '{{.driver}}' is not supported on {{.os}}" , out.V {"driver" : name , "os" : runtime .GOOS })
486
+ // validateSpecifiedDriver makes sure that if a user has passed in a driver
487
+ // it matches the existing cluster if there is one
488
+ func validateSpecifiedDriver (existing * config.ClusterConfig ) {
489
+ if existing == nil {
490
+ return
491
491
}
492
-
493
- st := ds .State
494
- glog .Infof ("status for %s: %+v" , name , st )
495
-
496
- if st .Error != nil {
497
- out .ErrLn ("" )
498
-
499
- out .WarningT ("'{{.driver}}' driver reported an issue: {{.error}}" , out.V {"driver" : name , "error" : st .Error })
500
- out .ErrT (out .Tip , "Suggestion: {{.fix}}" , out.V {"fix" : translate .T (st .Fix )})
501
- if st .Doc != "" {
502
- out .ErrT (out .Documentation , "Documentation: {{.url}}" , out.V {"url" : st .Doc })
503
- }
504
- out .ErrLn ("" )
505
-
506
- if ! st .Installed && ! viper .GetBool (force ) {
507
- if existing != nil && name == existing .Driver {
508
- exit .WithCodeT (exit .Unavailable , "{{.driver}} does not appear to be installed, but is specified by an existing profile. Please run 'minikube delete' or install {{.driver}}" , out.V {"driver" : name })
509
- }
510
- exit .WithCodeT (exit .Unavailable , "{{.driver}} does not appear to be installed" , out.V {"driver" : name })
511
- }
492
+ old := existing .Driver
493
+ var requested string
494
+ if d := viper .GetString ("driver" ); d != "" {
495
+ requested = d
496
+ } else if d := viper .GetString ("vm-driver" ); d != "" {
497
+ requested = d
512
498
}
513
-
514
- if existing == nil {
499
+ if old == requested {
515
500
return
516
501
}
517
502
@@ -525,33 +510,58 @@ func validateDriver(ds registry.DriverState, existing *config.ClusterConfig) {
525
510
if err != nil {
526
511
exit .WithError ("Error getting primary cp" , err )
527
512
}
528
-
529
513
machineName := driver .MachineName (* existing , cp )
530
514
h , err := api .Load (machineName )
531
515
if err != nil {
532
516
glog .Warningf ("selectDriver api.Load: %v" , err )
533
517
return
534
518
}
535
519
536
- if h .Driver .DriverName () == name {
537
- return
538
- }
539
-
540
- out .ErrT (out .Conflict , `The existing "{{.profile_name}}" VM that was created using the "{{.old_driver}}" driver, and is incompatible with the "{{.driver}}" driver.` ,
541
- out.V {"profile_name" : machineName , "driver" : name , "old_driver" : h .Driver .DriverName ()})
520
+ out .ErrT (out .Conflict , `The existing "{{.profile_name}}" VM was created using the "{{.old_driver}}" driver, and is incompatible with the "{{.driver}}" driver.` ,
521
+ out.V {"profile_name" : machineName , "driver" : requested , "old_driver" : h .Driver .DriverName ()})
542
522
543
523
out .ErrT (out .Workaround , `To proceed, either:
544
524
545
- 1) Delete the existing "{{.profile_name}}" cluster using: '{{.command}} delete'
525
+ 1) Delete the existing "{{.profile_name}}" cluster using: '{{.command}} delete'
546
526
547
- * or *
527
+ * or *
548
528
549
- 2) Start the existing "{{.profile_name}}" cluster using: '{{.command}} start --driver={{.old_driver}}'
550
- ` , out.V {"command" : minikubeCmd (), "old_driver" : h .Driver .DriverName (), "profile_name" : machineName })
529
+ 2) Start the existing "{{.profile_name}}" cluster using: '{{.command}} start --driver={{.old_driver}}'
530
+ ` , out.V {"command" : minikubeCmd (), "old_driver" : h .Driver .DriverName (), "profile_name" : machineName })
551
531
552
532
exit .WithCodeT (exit .Config , "Exiting." )
553
533
}
554
534
535
+ // validateDriver validates that the selected driver appears sane, exits if not
536
+ func validateDriver (ds registry.DriverState , existing * config.ClusterConfig ) {
537
+ name := ds .Name
538
+ glog .Infof ("validating driver %q against %+v" , name , existing )
539
+ if ! driver .Supported (name ) {
540
+ exit .WithCodeT (exit .Unavailable , "The driver {{.experimental}} '{{.driver}}' is not supported on {{.os}}" , out.V {"driver" : name , "os" : runtime .GOOS })
541
+ }
542
+
543
+ st := ds .State
544
+ glog .Infof ("status for %s: %+v" , name , st )
545
+
546
+ if st .Error != nil {
547
+ out .ErrLn ("" )
548
+
549
+ out .WarningT ("'{{.driver}}' driver reported an issue: {{.error}}" , out.V {"driver" : name , "error" : st .Error })
550
+ out .ErrT (out .Tip , "Suggestion: {{.fix}}" , out.V {"fix" : translate .T (st .Fix )})
551
+ if st .Doc != "" {
552
+ out .ErrT (out .Documentation , "Documentation: {{.url}}" , out.V {"url" : st .Doc })
553
+ }
554
+ out .ErrLn ("" )
555
+
556
+ if ! st .Installed && ! viper .GetBool (force ) {
557
+ if existing != nil && name == existing .Driver {
558
+ exit .WithCodeT (exit .Unavailable , "{{.driver}} does not appear to be installed, but is specified by an existing profile. Please run 'minikube delete' or install {{.driver}}" , out.V {"driver" : name })
559
+ }
560
+ exit .WithCodeT (exit .Unavailable , "{{.driver}} does not appear to be installed" , out.V {"driver" : name })
561
+ }
562
+ }
563
+ }
564
+
555
565
func selectImageRepository (mirrorCountry string , v semver.Version ) (bool , string , error ) {
556
566
var tryCountries []string
557
567
var fallback string
0 commit comments