mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-02-23 08:20:15 -05:00
cli: allow helm upgrades with old k8s patch version (#2095)
This commit is contained in:
parent
37af5f5f50
commit
26f4a13934
@ -255,7 +255,7 @@ func (c *Client) upgradeRelease(
|
|||||||
) error {
|
) error {
|
||||||
// We need to load all values that can be statically loaded before merging them with the cluster
|
// We need to load all values that can be statically loaded before merging them with the cluster
|
||||||
// values. Otherwise the templates are not rendered correctly.
|
// values. Otherwise the templates are not rendered correctly.
|
||||||
k8sVersion, err := versions.NewValidK8sVersion(conf.KubernetesVersion, true)
|
k8sVersion, err := versions.NewValidK8sVersion(conf.KubernetesVersion, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("validating k8s version: %s", conf.KubernetesVersion)
|
return fmt.Errorf("validating k8s version: %s", conf.KubernetesVersion)
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,8 @@ type ValidK8sVersion string
|
|||||||
// NewValidK8sVersion validates the given string and produces a new ValidK8sVersion object.
|
// NewValidK8sVersion validates the given string and produces a new ValidK8sVersion object.
|
||||||
// Returns an empty string if the given version is invalid.
|
// Returns an empty string if the given version is invalid.
|
||||||
// strict controls whether the patch version is checked or not.
|
// 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) {
|
func NewValidK8sVersion(k8sVersion string, strict bool) (ValidK8sVersion, error) {
|
||||||
var supported bool
|
var supported bool
|
||||||
if strict {
|
if strict {
|
||||||
@ -49,11 +51,14 @@ func NewValidK8sVersion(k8sVersion string, strict bool) (ValidK8sVersion, error)
|
|||||||
} else {
|
} else {
|
||||||
supported = isSupportedK8sVersion(k8sVersion)
|
supported = isSupportedK8sVersion(k8sVersion)
|
||||||
}
|
}
|
||||||
|
if !supported {
|
||||||
if supported {
|
return "", fmt.Errorf("invalid Kubernetes version: %s", k8sVersion)
|
||||||
return ValidK8sVersion(k8sVersion), nil
|
|
||||||
}
|
}
|
||||||
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.
|
// IsSupportedK8sVersion checks if a given Kubernetes minor version is supported by Constellation.
|
||||||
@ -82,6 +87,16 @@ func IsPreviewK8sVersion(_ ValidK8sVersion) bool {
|
|||||||
return false
|
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 (
|
const (
|
||||||
//
|
//
|
||||||
// Constellation images.
|
// Constellation images.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user