Skip to content

Commit

Permalink
Add CEL validation for target ref group
Browse files Browse the repository at this point in the history
  • Loading branch information
kate-osborn committed May 8, 2024
1 parent 74c027a commit 390fe3c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions apis/v1alpha1/clientsettingspolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type ClientSettingsPolicySpec struct {
// Support: Gateway, HTTPRoute, GRPCRoute.
//
// +kubebuilder:validation:XValidation:message="TargetRef Kind must be one of: Gateway, HTTPRoute, or GRPCRoute",rule="(self.kind=='Gateway' || self.kind=='HTTPRoute' || self.kind=='GRPCRoute')"
// +kubebuilder:validation:XValidation:message="TargetRef Group must be gateway.networking.k8s.io.",rule="(self.group=='gateway.networking.k8s.io')"
//nolint:lll
TargetRef gatewayv1alpha2.PolicyTargetReference `json:"targetRef"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ spec:
- message: 'TargetRef Kind must be one of: Gateway, HTTPRoute, or
GRPCRoute'
rule: (self.kind=='Gateway' || self.kind=='HTTPRoute' || self.kind=='GRPCRoute')
- message: TargetRef Group must be gateway.networking.k8s.io.
rule: (self.group=='gateway.networking.k8s.io')
required:
- targetRef
type: object
Expand Down
2 changes: 2 additions & 0 deletions deploy/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ spec:
- message: 'TargetRef Kind must be one of: Gateway, HTTPRoute, or
GRPCRoute'
rule: (self.kind=='Gateway' || self.kind=='HTTPRoute' || self.kind=='GRPCRoute')
- message: TargetRef Group must be gateway.networking.k8s.io.
rule: (self.group=='gateway.networking.k8s.io')
required:
- targetRef
type: object
Expand Down

0 comments on commit 390fe3c

Please sign in to comment.