mirror of
https://github.com/rancher/rke.git
synced 2025-09-01 23:16:22 +00:00
Modify kubernetes version check to allow upgrade
This commit is contained in:
committed by
Alena Prokharchyk
parent
6d21f0eec2
commit
9d85116568
44
util/util.go
44
util/util.go
@@ -68,50 +68,6 @@ func IsSymlink(file string) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// ValidateVersion - Return error if version is not valid
|
||||
// Is version major.minor >= oldest major.minor supported
|
||||
// Is version in the AllK8sVersions list
|
||||
// Is version not in the "bad" list
|
||||
func ValidateVersion(version string) error {
|
||||
// Create target version and current versions list
|
||||
targetVersion, err := StrToSemVer(version)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s is not valid semver", version)
|
||||
}
|
||||
currentVersionsList := []*semver.Version{}
|
||||
for _, ver := range v3.K8sVersionsCurrent {
|
||||
v, err := StrToSemVer(ver)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s in Current Versions list is not valid semver", ver)
|
||||
}
|
||||
|
||||
currentVersionsList = append(currentVersionsList, v)
|
||||
}
|
||||
|
||||
// Make sure Target version is greater than or equal to oldest major.minor supported.
|
||||
semver.Sort(currentVersionsList)
|
||||
if targetVersion.Major < currentVersionsList[0].Major {
|
||||
return fmt.Errorf("%s is an unsupported Kubernetes version - see 'rke config --system-images --all' for versions supported with this release", version)
|
||||
}
|
||||
if targetVersion.Major == currentVersionsList[0].Major {
|
||||
if targetVersion.Minor < currentVersionsList[0].Minor {
|
||||
return fmt.Errorf("%s is an unsupported Kubernetes version - see 'rke config --system-images --all' for versions supported with this release", version)
|
||||
}
|
||||
}
|
||||
// Make sure Target version is in the AllK8sVersions list.
|
||||
_, ok := v3.AllK8sVersions[version]
|
||||
if !ok {
|
||||
return fmt.Errorf("%s is an unsupported Kubernetes version - see 'rke config --system-images --all' for versions supported with this release", version)
|
||||
}
|
||||
// Make sure Target version is not "bad".
|
||||
_, ok = v3.K8sBadVersions[version]
|
||||
if ok {
|
||||
return fmt.Errorf("%s is an unsupported Kubernetes version - see 'rke config --system-images --all' for versions supported with this release", version)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetDefaultRKETools() string {
|
||||
return v3.AllK8sVersions[v3.DefaultK8s].Alpine
|
||||
}
|
||||
|
Reference in New Issue
Block a user