From 75a320f5907b7e08689eff16c86b6e725f52e991 Mon Sep 17 00:00:00 2001 From: Damyan Yordanov Date: Mon, 10 Jun 2024 14:02:12 +0200 Subject: [PATCH] Add dummy defaulter for each Webhook Otherwise the controller complains: `INFO controller-runtime.builder skip registering a mutating webhook, object does not implement admission.Defaulter or WithDefaulter wasn't called {"GVK": "ipam.metal.ironcore.dev/v1alpha1, Kind=IP"}` --- api/ipam/v1alpha1/ip_webhook.go | 6 ++++++ api/ipam/v1alpha1/network_webhook.go | 6 ++++++ api/ipam/v1alpha1/networkcounter_webhook.go | 6 ++++++ api/ipam/v1alpha1/subnet_webhook.go | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/api/ipam/v1alpha1/ip_webhook.go b/api/ipam/v1alpha1/ip_webhook.go index f198a5b..bce461c 100644 --- a/api/ipam/v1alpha1/ip_webhook.go +++ b/api/ipam/v1alpha1/ip_webhook.go @@ -35,6 +35,12 @@ func (in *IP) SetupWebhookWithManager(mgr ctrl.Manager) error { // +kubebuilder:webhook:path=/validate-ipam-metal-ironcore-dev-v1alpha1-ip,mutating=false,failurePolicy=fail,sideEffects=None,groups=ipam.metal.ironcore.dev,resources=ips,verbs=create;update;delete,versions=v1alpha1,name=vip.kb.io,admissionReviewVersions={v1,v1beta1} +var _ webhook.Defaulter = &IP{} + +func (in *IP) Default() { + iplog.Info("default", "name", in.Name) +} + var _ webhook.Validator = &IP{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type diff --git a/api/ipam/v1alpha1/network_webhook.go b/api/ipam/v1alpha1/network_webhook.go index a59cfd7..f3a8016 100644 --- a/api/ipam/v1alpha1/network_webhook.go +++ b/api/ipam/v1alpha1/network_webhook.go @@ -30,6 +30,12 @@ func (in *Network) SetupWebhookWithManager(mgr ctrl.Manager) error { // +kubebuilder:webhook:path=/validate-ipam-metal-ironcore-dev-v1alpha1-network,mutating=false,failurePolicy=fail,sideEffects=None,groups=ipam.metal.ironcore.dev,resources=networks,verbs=create;update;delete,versions=v1alpha1,name=vnetwork.kb.io,admissionReviewVersions={v1,v1beta1} +var _ webhook.Defaulter = &Network{} + +func (in *Network) Default() { + iplog.Info("default", "name", in.Name) +} + var _ webhook.Validator = &Network{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type diff --git a/api/ipam/v1alpha1/networkcounter_webhook.go b/api/ipam/v1alpha1/networkcounter_webhook.go index 006afd5..2f0d9dc 100644 --- a/api/ipam/v1alpha1/networkcounter_webhook.go +++ b/api/ipam/v1alpha1/networkcounter_webhook.go @@ -26,6 +26,12 @@ func (in *NetworkCounter) SetupWebhookWithManager(mgr ctrl.Manager) error { // +kubebuilder:webhook:path=/validate-ipam-metal-ironcore-dev-v1alpha1-networkcounter,mutating=false,failurePolicy=fail,sideEffects=None,groups=ipam.metal.ironcore.dev,resources=networkcounters,verbs=create;update;delete,versions=v1alpha1,name=vnetworkcounter.kb.io,admissionReviewVersions={v1,v1beta1} +var _ webhook.Defaulter = &NetworkCounter{} + +func (in *NetworkCounter) Default() { + iplog.Info("default", "name", in.Name) +} + var _ webhook.Validator = &NetworkCounter{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type diff --git a/api/ipam/v1alpha1/subnet_webhook.go b/api/ipam/v1alpha1/subnet_webhook.go index 7323e7f..7282fd1 100644 --- a/api/ipam/v1alpha1/subnet_webhook.go +++ b/api/ipam/v1alpha1/subnet_webhook.go @@ -83,6 +83,12 @@ func (in *Subnet) SetupWebhookWithManager(mgr ctrl.Manager) error { // +kubebuilder:webhook:path=/validate-ipam-metal-ironcore-dev-v1alpha1-subnet,mutating=false,failurePolicy=fail,sideEffects=None,groups=ipam.metal.ironcore.dev,resources=subnets,verbs=create;update;delete,versions=v1alpha1,name=vsubnet.kb.io,admissionReviewVersions={v1,v1beta1} +var _ webhook.Defaulter = &Subnet{} + +func (in *Subnet) Default() { + iplog.Info("default", "name", in.Name) +} + var _ webhook.Validator = &Subnet{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type