Skip to content

Commit ef23d9b

Browse files
committed
Add in CEL validation for TargetRefs
1 parent 85a217e commit ef23d9b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

apis/v1alpha1/proxysettingspolicy_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ type ProxySettingsPolicySpec struct {
4848
//
4949
// +kubebuilder:validation:MinItems=1
5050
// +kubebuilder:validation:MaxItems=16
51+
// +kubebuilder:validation:XValidation:message="TargetRefs entries must have kind Gateway, HTTPRoute, or GRPCRoute",rule="self.all(t, t.kind == 'Gateway' || t.kind == 'HTTPRoute' || t.kind == 'GRPCRoute')"
52+
// +kubebuilder:validation:XValidation:message="TargetRefs entries must have group gateway.networking.k8s.io",rule="self.all(t, t.group == 'gateway.networking.k8s.io')"
53+
// +kubebuilder:validation:XValidation:message="TargetRefs must be unique",rule="self.all(t1, self.exists_one(t2, t1.group == t2.group && t1.kind == t2.kind && t1.name == t2.name))"
54+
//nolint:lll
5155
TargetRefs []gatewayv1.LocalPolicyTargetReference `json:"targetRefs"`
5256
}
5357

@@ -93,5 +97,6 @@ type ProxyBuffers struct {
9397
// Number sets the number of buffers.
9498
//
9599
// +kubebuilder:validation:Minimum=2
100+
// +kubebuilder:validation:Maximum=256
96101
Number int32 `json:"number"`
97102
}

0 commit comments

Comments
 (0)