From e0d22487499419f9c88f4397104e51ca9426e845 Mon Sep 17 00:00:00 2001 From: Luca Bernstein Date: Mon, 4 Nov 2024 13:08:10 +0100 Subject: [PATCH] Remove the provider type predicates in webhooks --- pkg/admission/mutator/webhook.go | 9 +++------ pkg/admission/validator/webhook.go | 17 ++++++----------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/pkg/admission/mutator/webhook.go b/pkg/admission/mutator/webhook.go index cf5a320d2..84b213aa1 100644 --- a/pkg/admission/mutator/webhook.go +++ b/pkg/admission/mutator/webhook.go @@ -5,13 +5,11 @@ package mutator import ( - extensionspredicate "github.com/gardener/gardener/extensions/pkg/predicate" extensionswebhook "github.com/gardener/gardener/extensions/pkg/webhook" gardencorev1beta1 "github.com/gardener/gardener/pkg/apis/core/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/manager" - "sigs.k8s.io/controller-runtime/pkg/predicate" "github.com/gardener/gardener-extension-provider-openstack/pkg/openstack" ) @@ -28,10 +26,9 @@ func New(mgr manager.Manager) (*extensionswebhook.Webhook, error) { logger.Info("Setting up webhook", "name", Name) return extensionswebhook.New(mgr, extensionswebhook.Args{ - Provider: openstack.Type, - Name: Name, - Path: "/webhooks/mutate", - Predicates: []predicate.Predicate{extensionspredicate.GardenCoreProviderType(openstack.Type)}, + Provider: openstack.Type, + Name: Name, + Path: "/webhooks/mutate", Mutators: map[extensionswebhook.Mutator][]extensionswebhook.Type{ NewShootMutator(mgr): {{Obj: &gardencorev1beta1.Shoot{}}}, }, diff --git a/pkg/admission/validator/webhook.go b/pkg/admission/validator/webhook.go index d5eaf4480..bd58d1da6 100644 --- a/pkg/admission/validator/webhook.go +++ b/pkg/admission/validator/webhook.go @@ -5,7 +5,6 @@ package validator import ( - extensionspredicate "github.com/gardener/gardener/extensions/pkg/predicate" extensionswebhook "github.com/gardener/gardener/extensions/pkg/webhook" "github.com/gardener/gardener/pkg/apis/core" "github.com/gardener/gardener/pkg/apis/security" @@ -13,7 +12,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/manager" - "sigs.k8s.io/controller-runtime/pkg/predicate" "github.com/gardener/gardener-extension-provider-openstack/pkg/openstack" ) @@ -32,16 +30,13 @@ func New(mgr manager.Manager) (*extensionswebhook.Webhook, error) { logger.Info("Setting up webhook", "name", Name) return extensionswebhook.New(mgr, extensionswebhook.Args{ - Provider: openstack.Type, - Name: Name, - Path: "/webhooks/validate", - Predicates: []predicate.Predicate{extensionspredicate.GardenCoreProviderType(openstack.Type)}, + Provider: openstack.Type, + Name: Name, + Path: "/webhooks/validate", Validators: map[extensionswebhook.Validator][]extensionswebhook.Type{ - NewShootValidator(mgr): {{Obj: &core.Shoot{}}}, - NewCloudProfileValidator(mgr): {{Obj: &core.CloudProfile{}}}, - NewSecretBindingValidator(mgr): {{Obj: &core.SecretBinding{}}}, - // TODO(dimityrmirchev): Uncomment this line once this extension uses a g/g version that contains https://github.com/gardener/gardener/pull/10499 - // Predicates: []predicate.Predicate{predicate.Or(extensionspredicate.GardenCoreProviderType(openstack.Type), extensionspredicate.GardenSecurityProviderType(openstack.Type))}, + NewShootValidator(mgr): {{Obj: &core.Shoot{}}}, + NewCloudProfileValidator(mgr): {{Obj: &core.CloudProfile{}}}, + NewSecretBindingValidator(mgr): {{Obj: &core.SecretBinding{}}}, NewCredentialsBindingValidator(mgr): {{Obj: &security.CredentialsBinding{}}}, }, Target: extensionswebhook.TargetSeed,