Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(MeshHTTPRoute): add header matching #5943

Merged
29 changes: 29 additions & 0 deletions api/common/v1alpha1/header.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// +kubebuilder:object:generate=true
package v1alpha1

// +kubebuilder:validation:MinLength=1
Expand All @@ -6,3 +7,31 @@ package v1alpha1
type HeaderName string

type HeaderValue string

type HeaderMatchType string

// HeaderMatchType constants.
const (
HeaderMatchExact HeaderMatchType = "Exact"
HeaderMatchPresent HeaderMatchType = "Present"
HeaderMatchRegularExpression HeaderMatchType = "RegularExpression"
HeaderMatchAbsent HeaderMatchType = "Absent"
HeaderMatchPrefix HeaderMatchType = "Prefix"
)

// HeaderMatch describes how to select a HTTP route by matching HTTP request
michaelbeaumont marked this conversation as resolved.
Show resolved Hide resolved
// headers.
type HeaderMatch struct {
// Type specifies how to match against the value of the header.
// +optional
// +kubebuilder:default=Exact
// +kubebuilder:validation:Enum=Exact;Present;RegularExpression;Absent;Prefix
Type *HeaderMatchType `json:"type,omitempty"`

// Name is the name of the HTTP Header to be matched. Name MUST be lower case
// as they will be handled with case insensitivity (See https://tools.ietf.org/html/rfc7230#section-3.2).
Name HeaderName `json:"name"`

// Value is the value of HTTP Header to be matched.
Value HeaderValue `json:"value"`
michaelbeaumont marked this conversation as resolved.
Show resolved Hide resolved
}
20 changes: 20 additions & 0 deletions api/common/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 @@ -1356,6 +1356,40 @@ spec:
matches:
items:
properties:
headers:
items:
description: HeaderMatch describes how to select
a HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP
Header to be matched. Name MUST be lower
case as they will be handled with case insensitivity
(See https://tools.ietf.org/html/rfc7230#section-3.2).
maxLength: 256
minLength: 1
pattern: ^[a-z0-9!#$%&'*+\-.^_\x60|~]+$
type: string
type:
default: Exact
description: Type specifies how to match against
the value of the header.
enum:
- Exact
- Present
- RegularExpression
- Absent
- Prefix
type: string
value:
description: Value is the value of HTTP Header
to be matched.
type: string
required:
- name
- value
type: object
type: array
method:
enum:
- CONNECT
Expand Down Expand Up @@ -2294,8 +2328,8 @@ spec:
which must be present in the request for retries to
be attempted.
items:
description: HTTPHeaderMatch describes how to select
a HTTP route by matching HTTP request headers.
description: HeaderMatch describes how to select a
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down Expand Up @@ -2332,8 +2366,8 @@ spec:
A retry will be triggered if any of the header matches
match the upstream response headers.
items:
description: HTTPHeaderMatch describes how to select
a HTTP route by matching HTTP request headers.
description: HeaderMatch describes how to select a
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,40 @@ spec:
matches:
items:
properties:
headers:
items:
description: HeaderMatch describes how to select
a HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP
Header to be matched. Name MUST be lower
case as they will be handled with case insensitivity
(See https://tools.ietf.org/html/rfc7230#section-3.2).
maxLength: 256
minLength: 1
pattern: ^[a-z0-9!#$%&'*+\-.^_\x60|~]+$
type: string
type:
default: Exact
description: Type specifies how to match against
the value of the header.
enum:
- Exact
- Present
- RegularExpression
- Absent
- Prefix
type: string
value:
description: Value is the value of HTTP Header
to be matched.
type: string
required:
- name
- value
type: object
type: array
method:
enum:
- CONNECT
Expand Down Expand Up @@ -2294,8 +2328,8 @@ spec:
which must be present in the request for retries to
be attempted.
items:
description: HTTPHeaderMatch describes how to select
a HTTP route by matching HTTP request headers.
description: HeaderMatch describes how to select a
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down Expand Up @@ -2332,8 +2366,8 @@ spec:
A retry will be triggered if any of the header matches
match the upstream response headers.
items:
description: HTTPHeaderMatch describes how to select
a HTTP route by matching HTTP request headers.
description: HeaderMatch describes how to select a
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,40 @@ spec:
matches:
items:
properties:
headers:
items:
description: HeaderMatch describes how to select
a HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP
Header to be matched. Name MUST be lower
case as they will be handled with case insensitivity
(See https://tools.ietf.org/html/rfc7230#section-3.2).
maxLength: 256
minLength: 1
pattern: ^[a-z0-9!#$%&'*+\-.^_\x60|~]+$
type: string
type:
default: Exact
description: Type specifies how to match against
the value of the header.
enum:
- Exact
- Present
- RegularExpression
- Absent
- Prefix
type: string
value:
description: Value is the value of HTTP Header
to be matched.
type: string
required:
- name
- value
type: object
type: array
method:
enum:
- CONNECT
Expand Down Expand Up @@ -2491,8 +2525,8 @@ spec:
which must be present in the request for retries to
be attempted.
items:
description: HTTPHeaderMatch describes how to select
a HTTP route by matching HTTP request headers.
description: HeaderMatch describes how to select a
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down Expand Up @@ -2529,8 +2563,8 @@ spec:
A retry will be triggered if any of the header matches
match the upstream response headers.
items:
description: HTTPHeaderMatch describes how to select
a HTTP route by matching HTTP request headers.
description: HeaderMatch describes how to select a
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,40 @@ spec:
matches:
items:
properties:
headers:
items:
description: HeaderMatch describes how to select
a HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP
Header to be matched. Name MUST be lower
case as they will be handled with case insensitivity
(See https://tools.ietf.org/html/rfc7230#section-3.2).
maxLength: 256
minLength: 1
pattern: ^[a-z0-9!#$%&'*+\-.^_\x60|~]+$
type: string
type:
default: Exact
description: Type specifies how to match against
the value of the header.
enum:
- Exact
- Present
- RegularExpression
- Absent
- Prefix
type: string
value:
description: Value is the value of HTTP Header
to be matched.
type: string
required:
- name
- value
type: object
type: array
method:
enum:
- CONNECT
Expand Down Expand Up @@ -2314,8 +2348,8 @@ spec:
which must be present in the request for retries to
be attempted.
items:
description: HTTPHeaderMatch describes how to select
a HTTP route by matching HTTP request headers.
description: HeaderMatch describes how to select a
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down Expand Up @@ -2352,8 +2386,8 @@ spec:
A retry will be triggered if any of the header matches
match the upstream response headers.
items:
description: HTTPHeaderMatch describes how to select
a HTTP route by matching HTTP request headers.
description: HeaderMatch describes how to select a
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down
Loading