You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.
Copyright2022TheKubernetes Authors.
LicensedundertheApacheLicense, Version2.0 (the"License");
youmaynotusethisfileexceptincompliancewiththe License.
YoumayobtainacopyoftheLicenseathttp://www.apache.org/licenses/LICENSE-2.0Unlessrequiredbyapplicablelaworagreedtoinwriting, softwaredistributedundertheLicenseisdistributedonan"AS IS"BASIS,
WITHOUTWARRANTIESORCONDITIONSOFANYKIND, eitherexpressor implied.
SeetheLicenseforthespecificlanguagegoverningpermissionsandlimitationsundertheLicense.
*/packageoperationsimport (
"fmt""k8s.io/apimachinery/pkg/util/version"
)
funcupgradeCheck(current, targetstring) (isSupported, isCrossVersion, canSkipbool) {
currentVer, err:=version.ParseSemantic(current)
iferr!=nil {
returnfalse, false, false
}
targetVer, err:=version.ParseSemantic(target)
iferr!=nil {
returnfalse, false, false
}
returnupgradeCheckVersion(currentVer, targetVer)
}
funcupgradeCheckVersion(current, target*version.Version) (isSupported, isCrossVersion, canSkipbool) {
// no need to check major as only major 1 is supported// if current.Major() != target.Major() {// return false// }ifcurrent.Minor() ==target.Minor() {
ifcurrent.Patch() ==target.Patch() {
// just skip as the version is the samereturntrue, false, true
}
// upgrade to a patched versionreturntrue, false, false
} elseifcurrent.Minor() <target.Minor() {
ifcurrent.Minor()+1==target.Minor() {
// upgrade to a minor versionreturntrue, false, false
}
// upgrade multi-minor version, need to split into multiple upgrade tasksreturntrue, true, false
}
// downgrade is not supportedifcurrent.Minor()-1==target.Minor() {
// TODO downgrade to a minor version// this is just for test purpose, need to define if it should be supported in the futurereturntrue, false, false
}
returnfalse, false, false
}
funcisSupported(verstring) bool {
v, err:=version.ParseSemantic(ver)
iferr!=nil {
returnfalse
}
returnisSupportedVersion(v)
}
funcisSupportedVersion(ver*version.Version) bool {
// TODO a table of supported versions needs to be created in the docsifver.Major() !=1&&ver.Minor() <17 {
returnfalse
}
returntrue
}
// before this, we should make sure the version is supportedfuncgetCrossVersions(current, targetstring) []string {
versions:= []string{}
cur, err:=version.ParseSemantic(current)
iferr!=nil {
returnversions
}
tar, err:=version.ParseSemantic(target)
iferr!=nil {
returnversions
}
_, isCross, _:=upgradeCheckVersion(cur, tar)
if!isCross {
returnversions
}
tarMinor:=tar.Minor()
fori:=cur.Minor() +1; i<tarMinor; i++ {
versions=append(versions, fmt.Sprintf("v1.%d.0", i))
}
returnversions
}
ewfilemode100644ndex0000000..3d11a78++b/operations/version_test.go
f8d06843b70231dc6828b4811100dc36025cff71
The text was updated successfully, but these errors were encountered:
downgrade to a minor version
this is just for test purpose, need to define if it should be supported in the future
kubeadm-operator/operations/version.go
Line 59 in 9721e44
f8d06843b70231dc6828b4811100dc36025cff71
The text was updated successfully, but these errors were encountered: