mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-03 12:36:09 -04:00
cli: allow helm upgrades with old k8s patch version (#2095)
This commit is contained in:
parent
f96308b23e
commit
36dde5e2a5
2 changed files with 20 additions and 5 deletions
|
@ -42,6 +42,8 @@ type ValidK8sVersion string
|
|||
// NewValidK8sVersion validates the given string and produces a new ValidK8sVersion object.
|
||||
// Returns an empty string if the given version is invalid.
|
||||
// strict controls whether the patch version is checked or not.
|
||||
// If strict is false, the patch version is ignored and the returned
|
||||
// ValidK8sVersion is a supported patch version for the given major.minor version.
|
||||
func NewValidK8sVersion(k8sVersion string, strict bool) (ValidK8sVersion, error) {
|
||||
var supported bool
|
||||
if strict {
|
||||
|
@ -49,11 +51,14 @@ func NewValidK8sVersion(k8sVersion string, strict bool) (ValidK8sVersion, error)
|
|||
} else {
|
||||
supported = isSupportedK8sVersion(k8sVersion)
|
||||
}
|
||||
|
||||
if supported {
|
||||
return ValidK8sVersion(k8sVersion), nil
|
||||
if !supported {
|
||||
return "", fmt.Errorf("invalid Kubernetes version: %s", k8sVersion)
|
||||
}
|
||||
return "", fmt.Errorf("invalid Kubernetes version: %s", k8sVersion)
|
||||
if !strict {
|
||||
k8sVersion, _ = supportedVersionForMajorMinor(k8sVersion)
|
||||
}
|
||||
|
||||
return ValidK8sVersion(k8sVersion), nil
|
||||
}
|
||||
|
||||
// IsSupportedK8sVersion checks if a given Kubernetes minor version is supported by Constellation.
|
||||
|
@ -82,6 +87,16 @@ func IsPreviewK8sVersion(_ ValidK8sVersion) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func supportedVersionForMajorMinor(majorMinor string) (string, bool) {
|
||||
majorMinor = semver.MajorMinor(majorMinor)
|
||||
for _, valid := range SupportedK8sVersions() {
|
||||
if semver.MajorMinor(valid) == majorMinor {
|
||||
return valid, true
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
const (
|
||||
//
|
||||
// Constellation images.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue