Skip to content

Commit 6eb7e5e

Browse files
committed
Update ObservabilityPolicy API to have minimum one target ref (nginx#2753)
Update Observability API to have one minimum one target ref Problem: User wants ObservabilityPolicy CRD should require a minimum of 1 TargetRef. Solution: Add validation to have minimum one target ref for the ObservabilityPolicy CRDs.
1 parent cba2139 commit 6eb7e5e

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

apis/v1alpha1/observabilitypolicy_types.go

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type ObservabilityPolicySpec struct {
4747
// Objects must be in the same namespace as the policy.
4848
// Support: HTTPRoute, GRPCRoute.
4949
//
50+
// +kubebuilder:validation:MinItems=1
5051
// +kubebuilder:validation:MaxItems=16
5152
// +kubebuilder:validation:XValidation:message="TargetRef Kind must be: HTTPRoute or GRPCRoute",rule="(self.exists(t, t.kind=='HTTPRoute') || self.exists(t, t.kind=='GRPCRoute'))"
5253
// +kubebuilder:validation:XValidation:message="TargetRef Group must be gateway.networking.k8s.io.",rule="self.all(t, t.group=='gateway.networking.k8s.io')"

config/crd/bases/gateway.nginx.org_observabilitypolicies.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ spec:
8585
- name
8686
type: object
8787
maxItems: 16
88+
minItems: 1
8889
type: array
8990
x-kubernetes-validations:
9091
- message: 'TargetRef Kind must be: HTTPRoute or GRPCRoute'

deploy/crds.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ spec:
904904
- name
905905
type: object
906906
maxItems: 16
907+
minItems: 1
907908
type: array
908909
x-kubernetes-validations:
909910
- message: 'TargetRef Kind must be: HTTPRoute or GRPCRoute'

0 commit comments

Comments
 (0)