Skip to content

Commit

Permalink
Replace the provider type predicate in the admission webhook with the…
Browse files Browse the repository at this point in the history
… object label selector
  • Loading branch information
LucaBernstein committed Nov 21, 2024
1 parent 1e2e9ca commit 099f4a2
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pkg/admission/validator/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
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/core/v1beta1/constants"
corev1 "k8s.io/api/core/v1"
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"

ironcore "github.com/ironcore-dev/gardener-extension-provider-ironcore/pkg/ironcore"
"github.com/ironcore-dev/gardener-extension-provider-ironcore/pkg/ironcore"
)

const (
Expand All @@ -29,14 +29,17 @@ func New(mgr manager.Manager) (*extensionswebhook.Webhook, error) {
logger.Info("Setting up webhook", "name", Name)

return extensionswebhook.New(mgr, extensionswebhook.Args{
Provider: ironcore.Type,
Name: Name,
Path: "/webhooks/validate",
Predicates: []predicate.Predicate{extensionspredicate.GardenCoreProviderType(ironcore.Type)},
Provider: ironcore.Type,
Name: Name,
Path: "/webhooks/validate",
Validators: map[extensionswebhook.Validator][]extensionswebhook.Type{
NewShootValidator(mgr): {{Obj: &core.Shoot{}}},
NewSecretBindingValidator(mgr): {{Obj: &core.SecretBinding{}}},
},
Target: extensionswebhook.TargetSeed,
ObjectSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{constants.LabelExtensionProviderTypePrefix + ironcore.Type: "true"},
},
})
}

Expand Down

0 comments on commit 099f4a2

Please sign in to comment.