mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 06:16:08 -04:00
cli: add --kubernetes
flag (#1226)
The flag can be used to specify a Kubernetes version in format MAJOR.MINOR and let the CLI extend the value with the patch version.
This commit is contained in:
parent
477d667360
commit
da7a870f54
3 changed files with 105 additions and 13 deletions
|
@ -327,19 +327,35 @@ func (c *Config) validateK8sVersion(fl validator.FieldLevel) bool {
|
|||
if !semver.IsValid(configVersion) {
|
||||
return false
|
||||
}
|
||||
var extendedVersion string
|
||||
switch semver.MajorMinor(configVersion) {
|
||||
case semver.MajorMinor(string(versions.V1_24)):
|
||||
extendedVersion = string(versions.V1_24)
|
||||
case semver.MajorMinor(string(versions.V1_25)):
|
||||
extendedVersion = string(versions.V1_25)
|
||||
case semver.MajorMinor(string(versions.V1_26)):
|
||||
extendedVersion = string(versions.V1_26)
|
||||
default:
|
||||
|
||||
extendedVersion := K8sVersionFromMajorMinor(semver.MajorMinor(configVersion))
|
||||
if extendedVersion == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
valid := versions.IsSupportedK8sVersion(extendedVersion)
|
||||
if !valid {
|
||||
return false
|
||||
}
|
||||
|
||||
c.KubernetesVersion = extendedVersion
|
||||
return versions.IsSupportedK8sVersion(extendedVersion)
|
||||
return true
|
||||
}
|
||||
|
||||
// K8sVersionFromMajorMinor takes a semver in format MAJOR.MINOR
|
||||
// and returns the version in format MAJOR.MINOR.PATCH with the
|
||||
// supported patch version as PATCH.
|
||||
func K8sVersionFromMajorMinor(version string) string {
|
||||
switch version {
|
||||
case semver.MajorMinor(string(versions.V1_24)):
|
||||
return string(versions.V1_24)
|
||||
case semver.MajorMinor(string(versions.V1_25)):
|
||||
return string(versions.V1_25)
|
||||
case semver.MajorMinor(string(versions.V1_26)):
|
||||
return string(versions.V1_26)
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func registerVersionCompatibilityError(ut ut.Translator) error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue