Skip to content

Commit e809adf

Browse files
committed
fix: VRF webhook validation path
1 parent 833c5c3 commit e809adf

File tree

6 files changed

+7
-24
lines changed

6 files changed

+7
-24
lines changed

api/core/v1alpha1/vrf_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ type VRFStatus struct {
118118
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
119119

120120
// VRF is the Schema for the vrfs API
121-
// +kubebuilder:webhook:path=/validate-networking.metal.ironcore.dev-v1alpha1-vrf,mutating=false,failurePolicy=Fail,sideEffects=None,groups=networking.metal.ironcore.dev,resources=vrfs,verbs=create;update,versions=v1alpha1,name=vvrf.kb.io,admissionReviewVersions=v1
121+
// +kubebuilder:webhook:path=/validate-networking-metal-ironcore.dev-v1alpha1-vrf,mutating=false,failurePolicy=Fail,sideEffects=None,groups=networking.metal.ironcore.dev,resources=vrfs,verbs=create;update,versions=v1alpha1,name=vvrf.kb.io,admissionReviewVersions=v1
122122
type VRF struct {
123123
metav1.TypeMeta `json:",inline"`
124124
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`

charts/network-operator/templates/webhook/webhooks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ webhooks:
1616
service:
1717
name: network-operator-webhook-service
1818
namespace: {{ .Release.Namespace }}
19-
path: /validate-networking.metal.ironcore.dev-v1alpha1-vrf
19+
path: /validate-networking-metal-ironcore-dev-v1alpha1-vrf
2020
failurePolicy: Fail
2121
sideEffects: None
2222
admissionReviewVersions:

config/webhook/manifests.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ webhooks:
88
- v1
99
clientConfig:
1010
service:
11-
name: webhook-service
12-
namespace: system
13-
path: /validate-networking.metal.ironcore.dev-v1alpha1-vrf
11+
name: network-operator-webhook-service
12+
namespace: network-operator-system
13+
path: /validate-networking-metal-ironcore-dev-v1alpha1-vrf
1414
failurePolicy: Fail
1515
name: vrf-v1alpha1.kb.io
1616
rules:

config/webhook/service.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
app.kubernetes.io/name: network-operator
66
app.kubernetes.io/managed-by: kustomize
77
name: webhook-service
8+
namespace: network-operator-system
89
spec:
910
ports:
1011
- port: 443

internal/webhook/core/v1alpha1/vrf_webhook.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func SetupVRFWebhookWithManager(mgr ctrl.Manager) error {
3030
Complete()
3131
}
3232

33-
// +kubebuilder:webhook:path=/validate-networking.metal.ironcore.dev-v1alpha1-vrf,mutating=false,failurePolicy=Fail,sideEffects=None,groups=networking.metal.ironcore.dev,resources=vrfs,verbs=create;update,versions=v1alpha1,name=vrf-v1alpha1.kb.io,admissionReviewVersions=v1
33+
// +kubebuilder:webhook:path=/validate-networking-metal-ironcore-dev-v1alpha1-vrf,mutating=false,failurePolicy=Fail,sideEffects=None,groups=networking.metal.ironcore.dev,resources=vrfs,verbs=create;update,versions=v1alpha1,name=vrf-v1alpha1.kb.io,admissionReviewVersions=v1
3434

3535
// VRFCustomValidator struct is responsible for validating the VRF resource
3636
// when it is created, updated, or deleted.
@@ -62,11 +62,6 @@ func (v *VRFCustomValidator) ValidateUpdate(_ context.Context, oldObj, newObj ru
6262

6363
// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type VRF.
6464
func (v *VRFCustomValidator) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
65-
_, ok := obj.(*v1alpha1.VRF)
66-
if !ok {
67-
return nil, fmt.Errorf("expected a VRF object but got %T", obj)
68-
}
69-
7065
return nil, nil
7166
}
7267

internal/webhook/core/v1alpha1/vrf_webhook_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,6 @@ var _ = Describe("VRF Webhook", func() {
130130
})
131131
})
132132

133-
Context("ValidateDelete", func() {
134-
It("allows delete on VRF object", func() {
135-
_, err := validator.ValidateDelete(ctx, obj)
136-
Expect(err).ToNot(HaveOccurred())
137-
})
138-
139-
It("rejects delete when object type is wrong", func() {
140-
// Passing a different type (nil interface would panic so use something else)
141-
_, err := validator.ValidateDelete(ctx, &v1alpha1.VRFList{})
142-
Expect(err).To(HaveOccurred())
143-
})
144-
})
145-
146133
Context("ValidateCreate RouteTargets", func() {
147134
It("accepts valid type-0 route target", func() {
148135
obj.Spec.RouteTargets = []v1alpha1.RouteTarget{

0 commit comments

Comments
 (0)