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 an HTTP route by matching HTTP request
// 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,omitempty"`
}
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,39 @@ spec:
matches:
items:
properties:
headers:
items:
description: HeaderMatch describes how to select
an 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
type: object
type: array
method:
enum:
- CONNECT
Expand Down Expand Up @@ -2294,8 +2327,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 an
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down Expand Up @@ -2323,7 +2356,6 @@ spec:
type: string
required:
- name
- value
type: object
type: array
retriableResponseHeaders:
Expand All @@ -2332,8 +2364,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 an
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down Expand Up @@ -2361,7 +2393,6 @@ spec:
type: string
required:
- name
- value
type: object
type: array
retryOn:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,39 @@ spec:
matches:
items:
properties:
headers:
items:
description: HeaderMatch describes how to select
an 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
type: object
type: array
method:
enum:
- CONNECT
Expand Down Expand Up @@ -2294,8 +2327,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 an
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down Expand Up @@ -2323,7 +2356,6 @@ spec:
type: string
required:
- name
- value
type: object
type: array
retriableResponseHeaders:
Expand All @@ -2332,8 +2364,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 an
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down Expand Up @@ -2361,7 +2393,6 @@ spec:
type: string
required:
- name
- value
type: object
type: array
retryOn:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,39 @@ spec:
matches:
items:
properties:
headers:
items:
description: HeaderMatch describes how to select
an 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
type: object
type: array
method:
enum:
- CONNECT
Expand Down Expand Up @@ -2491,8 +2524,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 an
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down Expand Up @@ -2520,7 +2553,6 @@ spec:
type: string
required:
- name
- value
type: object
type: array
retriableResponseHeaders:
Expand All @@ -2529,8 +2561,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 an
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down Expand Up @@ -2558,7 +2590,6 @@ spec:
type: string
required:
- name
- value
type: object
type: array
retryOn:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,39 @@ spec:
matches:
items:
properties:
headers:
items:
description: HeaderMatch describes how to select
an 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
type: object
type: array
method:
enum:
- CONNECT
Expand Down Expand Up @@ -2314,8 +2347,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 an
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down Expand Up @@ -2343,7 +2376,6 @@ spec:
type: string
required:
- name
- value
type: object
type: array
retriableResponseHeaders:
Expand All @@ -2352,8 +2384,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 an
HTTP route by matching HTTP request headers.
properties:
name:
description: Name is the name of the HTTP Header
Expand Down Expand Up @@ -2381,7 +2413,6 @@ spec:
type: string
required:
- name
- value
type: object
type: array
retryOn:
Expand Down
Loading