Skip to content

Commit 89bae65

Browse files
committed
refactor(config): eliminate conditional webhook logic for STACKIT pod identity
Key changes: - Removed redundant `isShoot` method and related conditional logic
1 parent 8f87eff commit 89bae65

File tree

3 files changed

+1
-15
lines changed

3 files changed

+1
-15
lines changed

charts/internal/shoot-system-components/charts/stackit-pod-identity-webhook/values.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
enabled: true
21
webhook:
32
caBundle: "" # will be set by valuesprovider
43
# failurePolicy for the webhook (Ignore or Fail).

pkg/controller/controlplane/valuesprovider.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
secretsmanager "github.com/gardener/gardener/pkg/utils/secrets/manager"
3030
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
3131
appsv1 "k8s.io/api/apps/v1"
32-
v1 "k8s.io/api/apps/v1"
3332
corev1 "k8s.io/api/core/v1"
3433
networkingv1 "k8s.io/api/networking/v1"
3534
policyv1 "k8s.io/api/policy/v1"
@@ -368,12 +367,6 @@ type valuesProvider struct {
368367
customLabelDomain string
369368
}
370369

371-
// isShoot returns if the cluster is a shoot or a seed by checking if the gardenlet is present in cluster
372-
func (vp *valuesProvider) isShoot(ctx context.Context, cluster *extensionscontroller.Cluster) bool {
373-
err := vp.client.Get(ctx, k8sclient.ObjectKey{Name: "gardenlet", Namespace: "garden"}, &v1.Deployment{})
374-
return errors.IsNotFound(err)
375-
}
376-
377370
// GetConfigChartValues returns the values for the config chart applied by the generic actuator.
378371
func (vp *valuesProvider) GetConfigChartValues(
379372
ctx context.Context,
@@ -1083,8 +1076,7 @@ func (vp *valuesProvider) getControlPlaneShootChartValues(ctx context.Context, c
10831076
return nil, err
10841077
}
10851078

1086-
isShoot := vp.isShoot(ctx, cluster)
1087-
podIdentityWebhook, err := vp.getSTACKITPodIdentityWebhookShootChartValues(isShoot, secretsReader)
1079+
podIdentityWebhook, err := vp.getSTACKITPodIdentityWebhookShootChartValues(secretsReader)
10881080
if err != nil {
10891081
return nil, err
10901082
}
@@ -1319,7 +1311,6 @@ func getSTACKITPodIdentityWebhookChartValues(
13191311
}
13201312

13211313
func (vp *valuesProvider) getSTACKITPodIdentityWebhookShootChartValues(
1322-
isShoot bool,
13231314
secretsReader secretsmanager.Reader,
13241315
) (map[string]any, error) {
13251316
caSecret, found := secretsReader.Get(caNameControlPlane)
@@ -1328,7 +1319,6 @@ func (vp *valuesProvider) getSTACKITPodIdentityWebhookShootChartValues(
13281319
}
13291320

13301321
return map[string]any{
1331-
"enabled": isShoot,
13321322
"webhook": map[string]any{
13331323
"caBundle": gardenerutils.EncodeBase64(caSecret.Data[secretutils.DataKeyCertificateBundle]),
13341324
},

pkg/controller/controlplane/valuesprovider_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,6 @@ var _ = Describe("ValuesProvider", func() {
893893

894894
Describe("#GetControlPlaneShootChartValues", func() {
895895
stackitPodIdentityWebhookChartShootValues := map[string]any{
896-
"enabled": true,
897896
"webhook": map[string]any{
898897
"caBundle": "",
899898
},
@@ -910,7 +909,6 @@ var _ = Describe("ValuesProvider", func() {
910909
// Refactoring led to retrieving it three times at a lower level
911910
// This is the vp.getCredentials() call
912911
c.EXPECT().Get(ctx, cpSecretKey, &corev1.Secret{}).DoAndReturn(clientGet(cpSecret)).Times(2)
913-
c.EXPECT().Get(ctx, client.ObjectKey{Name: "gardenlet", Namespace: "garden"}, &appsv1.Deployment{}).Return(errors.NewNotFound(schema.GroupResource{Group: "apps", Resource: "deployments"}, "gardenlet"))
914912

915913
expectCSICleanupinControlPlane(ctx, c, openstack.CSIControllerName)
916914

@@ -929,7 +927,6 @@ var _ = Describe("ValuesProvider", func() {
929927

930928
It("should return correct shoot control plane chart if CSI STACKIT is enabled", func() {
931929
c.EXPECT().Get(ctx, cpSecretKey, &corev1.Secret{}).DoAndReturn(clientGet(cpSecret)).Times(2)
932-
c.EXPECT().Get(ctx, client.ObjectKey{Name: "gardenlet", Namespace: "garden"}, &appsv1.Deployment{}).Return(errors.NewNotFound(schema.GroupResource{Group: "apps", Resource: "deployments"}, "gardenlet"))
933930

934931
expectCSICleanupinControlPlane(ctx, c, openstack.CSIControllerName)
935932

0 commit comments

Comments
 (0)