From c127b376d7fd5149fafc19b05b6f98e7a9f7062e Mon Sep 17 00:00:00 2001 From: Rudrakh Panigrahi Date: Sat, 14 Sep 2024 07:42:59 +0530 Subject: [PATCH] api: support inverting matches in rate limit (#4176) --- api/v1alpha1/ratelimit_types.go | 16 +++++++++++++ api/v1alpha1/zz_generated.deepcopy.go | 10 ++++++++ ....envoyproxy.io_backendtrafficpolicies.yaml | 24 +++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/api/v1alpha1/ratelimit_types.go b/api/v1alpha1/ratelimit_types.go index 9228e7d4b87..deb859400f8 100644 --- a/api/v1alpha1/ratelimit_types.go +++ b/api/v1alpha1/ratelimit_types.go @@ -138,6 +138,13 @@ type SourceMatch struct { // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=256 Value string `json:"value"` + + // Invert specifies whether the value match result will be inverted. + // + // +optional + // +kubebuilder:default=false + // +notImplementedHide + Invert *bool `json:"invert,omitempty"` } // HeaderMatch defines the match attributes within the HTTP Headers of the request. @@ -161,6 +168,15 @@ type HeaderMatch struct { // TODO: zhaohuabing this type could be replaced with // +optional // +kubebuilder:validation:MaxLength=1024 Value *string `json:"value,omitempty"` + + // Invert specifies whether the value match result will be inverted. + // Do not set this field when Type="Distinct", implying matching on any/all unique + // values within the header. + // + // +optional + // +kubebuilder:default=false + // +notImplementedHide + Invert *bool `json:"invert,omitempty"` } // HeaderMatchType specifies the semantics of how HTTP header values should be compared. diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 7ee438d5b14..d1c42376011 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -2816,6 +2816,11 @@ func (in *HeaderMatch) DeepCopyInto(out *HeaderMatch) { *out = new(string) **out = **in } + if in.Invert != nil { + in, out := &in.Invert, &out.Invert + *out = new(bool) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HeaderMatch. @@ -4862,6 +4867,11 @@ func (in *SourceMatch) DeepCopyInto(out *SourceMatch) { *out = new(SourceMatchType) **out = **in } + if in.Invert != nil { + in, out := &in.Invert, &out.Invert + *out = new(bool) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SourceMatch. diff --git a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml index eb41bae8b0f..77133a803fc 100644 --- a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml +++ b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml @@ -693,6 +693,13 @@ spec: description: HeaderMatch defines the match attributes within the HTTP Headers of the request. properties: + invert: + default: false + description: |- + Invert specifies whether the value match result will be inverted. + Do not set this field when Type="Distinct", implying matching on any/all unique + values within the header. + type: boolean name: description: Name of the HTTP header. maxLength: 256 @@ -728,6 +735,11 @@ spec: SourceCIDR is the client IP Address range to match on. At least one of headers or sourceCIDR condition must be specified. properties: + invert: + default: false + description: Invert specifies whether the + value match result will be inverted. + type: boolean type: default: Exact enum: @@ -824,6 +836,13 @@ spec: description: HeaderMatch defines the match attributes within the HTTP Headers of the request. properties: + invert: + default: false + description: |- + Invert specifies whether the value match result will be inverted. + Do not set this field when Type="Distinct", implying matching on any/all unique + values within the header. + type: boolean name: description: Name of the HTTP header. maxLength: 256 @@ -859,6 +878,11 @@ spec: SourceCIDR is the client IP Address range to match on. At least one of headers or sourceCIDR condition must be specified. properties: + invert: + default: false + description: Invert specifies whether the + value match result will be inverted. + type: boolean type: default: Exact enum: