Improve minikubeCmd, promote to public function
parent
81393a0bc3
commit
b99e943684
|
|
@ -17,22 +17,10 @@ limitations under the License.
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
)
|
||||
|
||||
// Return a minikube command containing the current profile name
|
||||
func minikubeCmd() string {
|
||||
cname := ClusterFlagValue()
|
||||
if cname != constants.DefaultClusterName {
|
||||
return fmt.Sprintf("minikube -p %s", cname)
|
||||
}
|
||||
return "minikube"
|
||||
}
|
||||
|
||||
// ClusterFlagValue returns the current cluster name based on flags
|
||||
func ClusterFlagValue() string {
|
||||
return viper.GetString(config.ProfileName)
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ import (
|
|||
"k8s.io/minikube/pkg/minikube/kubeconfig"
|
||||
"k8s.io/minikube/pkg/minikube/localpath"
|
||||
"k8s.io/minikube/pkg/minikube/machine"
|
||||
"k8s.io/minikube/pkg/minikube/mustload"
|
||||
"k8s.io/minikube/pkg/minikube/node"
|
||||
"k8s.io/minikube/pkg/minikube/notify"
|
||||
"k8s.io/minikube/pkg/minikube/out"
|
||||
|
|
@ -550,15 +551,9 @@ func validateSpecifiedDriver(existing *config.ClusterConfig) {
|
|||
if err != nil {
|
||||
exit.WithError("Error getting primary cp", err)
|
||||
}
|
||||
machineName := driver.MachineName(*existing, cp)
|
||||
h, err := api.Load(machineName)
|
||||
if err != nil {
|
||||
glog.Warningf("selectDriver api.Load: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
out.ErrT(out.Conflict, `The existing "{{.profile_name}}" VM was created using the "{{.old_driver}}" driver, and is incompatible with the "{{.driver}}" driver.`,
|
||||
out.V{"profile_name": machineName, "driver": requested, "old_driver": h.Driver.DriverName()})
|
||||
out.ErrT(out.Conflict, `The existing "{{.name}}" ccluster was created using the "{{.old}}" driver, and is incompatible with the "{{.new}}" driver.`,
|
||||
out.V{"name": existing.Name, "new": requested, "old": h.Driver.DriverName()})
|
||||
|
||||
out.ErrT(out.Workaround, `To proceed, either:
|
||||
|
||||
|
|
@ -566,8 +561,8 @@ func validateSpecifiedDriver(existing *config.ClusterConfig) {
|
|||
|
||||
* or *
|
||||
|
||||
2) Start the existing "{{.profile_name}}" cluster using: '{{.command}} start --driver={{.old_driver}}'
|
||||
`, out.V{"command": minikubeCmd(), "old_driver": h.Driver.DriverName(), "profile_name": machineName})
|
||||
2) Start the existing "{{.profile_name}}" cluster using: '{{.command}} --driver={{.old_driver}}'
|
||||
`, out.V{"command": mustload.ExampleCmd(existing.Name, "start"), "old_driver": h.Driver.DriverName(), "profile_name": cname})
|
||||
|
||||
exit.WithCodeT(exit.Config, "Exiting.")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,17 +153,17 @@ func Healthy(name string) ClusterController {
|
|||
return co
|
||||
}
|
||||
|
||||
// Return a minikube command containing the current profile name
|
||||
func minikubeCmd(cname string) string {
|
||||
// ExampleCmd Return a minikube command containing the current profile name
|
||||
func ExampleCmd(cname string, action string) string {
|
||||
if cname != constants.DefaultClusterName {
|
||||
return fmt.Sprintf("minikube -p %s", cname)
|
||||
return fmt.Sprintf("minikube %s -p %s", action, cname)
|
||||
}
|
||||
return "minikube"
|
||||
return fmt.Sprintf("minikube %s", action)
|
||||
}
|
||||
|
||||
// exitTip returns an action tip and exits
|
||||
func exitTip(action string, profile string, code int) {
|
||||
command := minikubeCmd(profile) + " " + action
|
||||
command := ExampleCmd(profile, action)
|
||||
out.T(out.Workaround, "To fix this, run: {{.command}}", out.V{"command": command})
|
||||
os.Exit(code)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue