move helper

pull/11632/head
Ilya Zuyev 2021-06-21 19:03:21 -07:00
parent cfb44b3708
commit 68749e13b7
2 changed files with 15 additions and 13 deletions

View File

@ -270,8 +270,8 @@ func disableOthers(me Manager, cr CommandRunner) error {
var requiredContainerdVersion = semver.MustParse("1.4.0") var requiredContainerdVersion = semver.MustParse("1.4.0")
// CompatibleWithVersion checks if current version of "runtime" is compatible with version "v" // compatibleWithVersion checks if current version of "runtime" is compatible with version "v"
func CompatibleWithVersion(runtime, v string) error { func compatibleWithVersion(runtime, v string) error {
vv, err := semver.Make(v) vv, err := semver.Make(v)
if err != nil { if err != nil {
return err return err
@ -283,3 +283,13 @@ func CompatibleWithVersion(runtime, v string) error {
} }
return nil return nil
} }
// CheckCompatibility checks if the container runtime managed by "cr" is compatible with current minikube code
// returns: NewErrRuntimeVersion if not
func CheckCompatibility(cr Manager) error {
v, err := cr.Version()
if err != nil {
return errors.Wrap(err, "Failed to check container runtime version")
}
return compatibleWithVersion(cr.Name(), v)
}

View File

@ -99,7 +99,7 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) {
cr := configureRuntimes(starter.Runner, *starter.Cfg, sv) cr := configureRuntimes(starter.Runner, *starter.Cfg, sv)
// check if installed runtime is compatible with current minikube code // check if installed runtime is compatible with current minikube code
if err = validateRuntimeVersion(cr); err != nil { if err = cruntime.CheckCompatibility(cr); err != nil {
return nil, err return nil, err
} }
@ -229,14 +229,6 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) {
return kcs, config.Write(viper.GetString(config.ProfileName), starter.Cfg) return kcs, config.Write(viper.GetString(config.ProfileName), starter.Cfg)
} }
func validateRuntimeVersion(cr cruntime.Manager) error {
v, err := cr.Version()
if err != nil {
return errors.Wrap(err, "Failed to check container runtime version")
}
return cruntime.CompatibleWithVersion(cr.Name(), v)
}
// joinCluster adds new or prepares and then adds existing node to the cluster. // joinCluster adds new or prepares and then adds existing node to the cluster.
func joinCluster(starter Starter, cpBs bootstrapper.Bootstrapper, bs bootstrapper.Bootstrapper) error { func joinCluster(starter Starter, cpBs bootstrapper.Bootstrapper, bs bootstrapper.Bootstrapper) error {
start := time.Now() start := time.Now()