diff --git a/apis/v1alpha1/observabilitypolicy_types.go b/apis/v1alpha1/observabilitypolicy_types.go index 6e95d28ccf..99b09e4ff9 100644 --- a/apis/v1alpha1/observabilitypolicy_types.go +++ b/apis/v1alpha1/observabilitypolicy_types.go @@ -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')" diff --git a/config/crd/bases/gateway.nginx.org_observabilitypolicies.yaml b/config/crd/bases/gateway.nginx.org_observabilitypolicies.yaml index d55574e353..8a27d84594 100644 --- a/config/crd/bases/gateway.nginx.org_observabilitypolicies.yaml +++ b/config/crd/bases/gateway.nginx.org_observabilitypolicies.yaml @@ -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' diff --git a/deploy/crds.yaml b/deploy/crds.yaml index 1e87d74771..6c619d5511 100644 --- a/deploy/crds.yaml +++ b/deploy/crds.yaml @@ -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'