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

@ -166,11 +166,11 @@ var ErrContainerRuntimeNotRunning = errors.New("container runtime is not running
// ErrRuntimeVersion is the error returned when disk image has incompatible version of service
type ErrRuntimeVersion struct {
// Service is the name of the incompatible service
Service string
Service string
// Installed is the installed version of Service
Installed string
// Required is the minimum required version of Service
Required string
Required string
}
// NewErrRuntimeVersion creates a new ErrRuntimeVersion
@ -270,8 +270,8 @@ func disableOthers(me Manager, cr CommandRunner) error {
var requiredContainerdVersion = semver.MustParse("1.4.0")
// CompatibleWithVersion checks if current version of "runtime" is compatible with version "v"
func CompatibleWithVersion(runtime, v string) error {
// compatibleWithVersion checks if current version of "runtime" is compatible with version "v"
func compatibleWithVersion(runtime, v string) error {
vv, err := semver.Make(v)
if err != nil {
return err
@ -283,3 +283,13 @@ func CompatibleWithVersion(runtime, v string) error {
}
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)
// 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
}
@ -229,14 +229,6 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) {
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.
func joinCluster(starter Starter, cpBs bootstrapper.Bootstrapper, bs bootstrapper.Bootstrapper) error {
start := time.Now()