Skip to content

Commit

Permalink
feat(MeshHTTPRoute): add header matching (#5943)
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Beaumont <mjboamail@gmail.com>
  • Loading branch information
michaelbeaumont committed Feb 8, 2023
1 parent f556179 commit 321bece
Show file tree
Hide file tree
Showing 29 changed files with 713 additions and 121 deletions.
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 @@ -1369,6 +1369,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 @@ -2307,8 +2340,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 @@ -2336,7 +2369,6 @@ spec:
type: string
required:
- name
- value
type: object
type: array
retriableResponseHeaders:
Expand All @@ -2345,8 +2377,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 @@ -2374,7 +2406,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 @@ -1369,6 +1369,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 @@ -2307,8 +2340,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 @@ -2336,7 +2369,6 @@ spec:
type: string
required:
- name
- value
type: object
type: array
retriableResponseHeaders:
Expand All @@ -2345,8 +2377,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 @@ -2374,7 +2406,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 @@ -1521,6 +1521,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 @@ -2504,8 +2537,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 @@ -2533,7 +2566,6 @@ spec:
type: string
required:
- name
- value
type: object
type: array
retriableResponseHeaders:
Expand All @@ -2542,8 +2574,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 @@ -2571,7 +2603,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 @@ -1389,6 +1389,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 @@ -2327,8 +2360,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 @@ -2356,7 +2389,6 @@ spec:
type: string
required:
- name
- value
type: object
type: array
retriableResponseHeaders:
Expand All @@ -2365,8 +2397,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 @@ -2394,7 +2426,6 @@ spec:
type: string
required:
- name
- value
type: object
type: array
retryOn:
Expand Down
Loading

0 comments on commit 321bece

Please sign in to comment.