Skip to content

Commit

Permalink
user gardener util funcs to check version
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBurger committed Nov 5, 2024
1 parent d547036 commit a68e09c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pkg/controller/controlplane/valuesprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"path/filepath"
"strings"

"github.com/Masterminds/semver/v3"
extensionscontroller "github.com/gardener/gardener/extensions/pkg/controller"
"github.com/gardener/gardener/extensions/pkg/controller/controlplane/genericactuator"
extensionssecretsmanager "github.com/gardener/gardener/extensions/pkg/util/secret/manager"
Expand All @@ -23,8 +24,8 @@ import (
kutil "github.com/gardener/gardener/pkg/utils/kubernetes"
secretutils "github.com/gardener/gardener/pkg/utils/secrets"
secretsmanager "github.com/gardener/gardener/pkg/utils/secrets/manager"
versionutils "github.com/gardener/gardener/pkg/utils/version"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"golang.org/x/mod/semver"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -477,13 +478,11 @@ func getCSIControllerChartValues(
},
}

// golang mod's semver considers only semvers starting with 'v' to be proper semver, so we need to do some checking/converting here.
// On the bright side, it can handle the shoot-spec-supported case of partial semvers, e.g.: (v)1.31
k8sVersion := cluster.Shoot.Spec.Kubernetes.Version
if !strings.HasPrefix(k8sVersion, "v") {
k8sVersion = "v" + k8sVersion
k8sVersion, err := semver.NewVersion(cluster.Shoot.Spec.Kubernetes.Version)
if err != nil {
return nil, err
}
if semver.Compare(k8sVersion, "v1.30.0") > 0 {
if versionutils.ConstraintK8sGreaterEqual131.Check(k8sVersion) {
if _, ok := cluster.Shoot.Annotations[gcp.AnnotationEnableVolumeAttributesClass]; ok {
values["csiDriver"] = map[string]interface{}{
"storage": map[string]interface{}{
Expand Down

0 comments on commit a68e09c

Please sign in to comment.