Skip to content

Commit

Permalink
api: support inverting matches in rate limit (#4176)
Browse files Browse the repository at this point in the history
  • Loading branch information
rudrakhp authored Sep 14, 2024
1 parent 5d406d2 commit c127b37
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
16 changes: 16 additions & 0 deletions api/v1alpha1/ratelimit_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c127b37

Please sign in to comment.