Skip to content

Commit

Permalink
Update ObservabilityPolicy API to have minimum one target ref (#2753)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
salonichf5 authored Nov 22, 2024
1 parent cafbd5c commit d54377f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions apis/v1alpha1/observabilitypolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type ObservabilityPolicySpec struct {
// Objects must be in the same namespace as the policy.
// Support: HTTPRoute, GRPCRoute.
//
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=16
// +kubebuilder:validation:XValidation:message="TargetRef Kind must be: HTTPRoute or GRPCRoute",rule="(self.exists(t, t.kind=='HTTPRoute') || self.exists(t, t.kind=='GRPCRoute'))"
// +kubebuilder:validation:XValidation:message="TargetRef Group must be gateway.networking.k8s.io.",rule="self.all(t, t.group=='gateway.networking.k8s.io')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ spec:
- name
type: object
maxItems: 16
minItems: 1
type: array
x-kubernetes-validations:
- message: 'TargetRef Kind must be: HTTPRoute or GRPCRoute'
Expand Down
1 change: 1 addition & 0 deletions deploy/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ spec:
- name
type: object
maxItems: 16
minItems: 1
type: array
x-kubernetes-validations:
- message: 'TargetRef Kind must be: HTTPRoute or GRPCRoute'
Expand Down

0 comments on commit d54377f

Please sign in to comment.