generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 472
/
httproute_types.go
359 lines (314 loc) · 12.9 KB
/
httproute_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/gateway-api/apis/v1beta1"
)
// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=gateway-api
// +kubebuilder:subresource:status
// +kubebuilder:deprecatedversion:warning="The v1alpha2 version of HTTPRoute has been deprecated and will be removed in a future release of the API. Please upgrade to v1beta1."
// +kubebuilder:printcolumn:name="Hostnames",type=string,JSONPath=`.spec.hostnames`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
// HTTPRoute provides a way to route HTTP requests. This includes the capability
// to match requests by hostname, path, header, or query param. Filters can be
// used to specify additional processing steps. Backends specify where matching
// requests should be routed.
type HTTPRoute v1beta1.HTTPRoute
// +kubebuilder:object:root=true
// HTTPRouteList contains a list of HTTPRoute.
type HTTPRouteList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []HTTPRoute `json:"items"`
}
// HTTPRouteSpec defines the desired state of HTTPRoute
// +k8s:deepcopy-gen=false
type HTTPRouteSpec = v1beta1.HTTPRouteSpec
// HTTPRouteRule defines semantics for matching an HTTP request based on
// conditions (matches), processing it (filters), and forwarding the request to
// an API object (backendRefs).
// +k8s:deepcopy-gen=false
type HTTPRouteRule = v1beta1.HTTPRouteRule
// PathMatchType specifies the semantics of how HTTP paths should be compared.
// Valid PathMatchType values are:
//
// * "Exact"
// * "PathPrefix"
// * "RegularExpression"
//
// PathPrefix and Exact paths must be syntactically valid:
//
// - Must begin with the `/` character
// - Must not contain consecutive `/` characters (e.g. `/foo///`, `//`).
//
// Note that values may be added to this enum, implementations
// must ensure that unknown values will not cause a crash.
//
// Unknown values here must result in the implementation setting the
// Accepted Condition for the Route to `status: False`, with a
// Reason of `UnsupportedValue`.
//
// +kubebuilder:validation:Enum=Exact;PathPrefix;RegularExpression
// +k8s:deepcopy-gen=false
type PathMatchType = v1beta1.PathMatchType
const (
// Matches the URL path exactly and with case sensitivity.
PathMatchExact PathMatchType = "Exact"
// Matches based on a URL path prefix split by `/`. Matching is
// case sensitive and done on a path element by element basis. A
// path element refers to the list of labels in the path split by
// the `/` separator. When specified, a trailing `/` is ignored.
//
// For example, the paths `/abc`, `/abc/`, and `/abc/def` would all match
// the prefix `/abc`, but the path `/abcd` would not.
//
// "PathPrefix" is semantically equivalent to the "Prefix" path type in the
// Kubernetes Ingress API.
PathMatchPathPrefix PathMatchType = "PathPrefix"
// Matches if the URL path matches the given regular expression with
// case sensitivity.
//
// Since `"RegularExpression"` has implementation-specific conformance,
// implementations can support POSIX, PCRE, RE2 or any other regular expression
// dialect.
// Please read the implementation's documentation to determine the supported
// dialect.
PathMatchRegularExpression PathMatchType = "RegularExpression"
)
// HTTPPathMatch describes how to select a HTTP route by matching the HTTP request path.
// +k8s:deepcopy-gen=false
type HTTPPathMatch = v1beta1.HTTPPathMatch
// HeaderMatchType specifies the semantics of how HTTP header values should be
// compared. Valid HeaderMatchType values are:
//
// * "Exact"
// * "RegularExpression"
//
// Note that values may be added to this enum, implementations
// must ensure that unknown values will not cause a crash.
//
// Unknown values here must result in the implementation setting the
// Accepted Condition for the Route to `status: False`, with a
// Reason of `UnsupportedValue`.
//
// +kubebuilder:validation:Enum=Exact;RegularExpression
// +k8s:deepcopy-gen=false
type HeaderMatchType = v1beta1.HeaderMatchType
// HeaderMatchType constants.
const (
HeaderMatchExact = v1beta1.HeaderMatchExact
HeaderMatchRegularExpression = v1beta1.HeaderMatchRegularExpression
)
// HTTPHeaderName is the name of an HTTP header.
//
// Valid values include:
// * "Authorization"
// * "Set-Cookie"
//
// Invalid values include:
//
// - ":method" - ":" is an invalid character. This means that HTTP/2 pseudo
// headers are not currently supported by this type.
//
// * "/invalid" - "/" is an invalid character
//
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=256
// +kubebuilder:validation:Pattern=`^[A-Za-z0-9!#$%&'*+\-.^_\x60|~]+$`
// +k8s:deepcopy-gen=false
type HTTPHeaderName = v1beta1.HTTPHeaderName
// HTTPHeaderMatch describes how to select a HTTP route by matching HTTP request
// headers.
// +k8s:deepcopy-gen=false
type HTTPHeaderMatch = v1beta1.HTTPHeaderMatch
// QueryParamMatchType specifies the semantics of how HTTP query parameter
// values should be compared. Valid QueryParamMatchType values are:
//
// * "Exact"
// * "RegularExpression"
//
// Note that values may be added to this enum, implementations
// must ensure that unknown values will not cause a crash.
//
// Unknown values here must result in the implementation setting the
// Accepted Condition for the Route to `status: False`, with a
// Reason of `UnsupportedValue`.
//
// +kubebuilder:validation:Enum=Exact;RegularExpression
// +k8s:deepcopy-gen=false
type QueryParamMatchType = v1beta1.QueryParamMatchType
// QueryParamMatchType constants.
const (
QueryParamMatchExact QueryParamMatchType = "Exact"
QueryParamMatchRegularExpression QueryParamMatchType = "RegularExpression"
)
// HTTPQueryParamMatch describes how to select a HTTP route by matching HTTP
// query parameters.
// +k8s:deepcopy-gen=false
type HTTPQueryParamMatch = v1beta1.HTTPQueryParamMatch
// HTTPMethod describes how to select a HTTP route by matching the HTTP
// method as defined by
// [RFC 7231](https://datatracker.ietf.org/doc/html/rfc7231#section-4) and
// [RFC 5789](https://datatracker.ietf.org/doc/html/rfc5789#section-2).
// The value is expected in upper case.
//
// Note that values may be added to this enum, implementations
// must ensure that unknown values will not cause a crash.
//
// Unknown values here must result in the implementation setting the
// Accepted Condition for the Route to `status: False`, with a
// Reason of `UnsupportedValue`.
//
// +kubebuilder:validation:Enum=GET;HEAD;POST;PUT;DELETE;CONNECT;OPTIONS;TRACE;PATCH
// +k8s:deepcopy-gen=false
type HTTPMethod = v1beta1.HTTPMethod
const (
HTTPMethodGet HTTPMethod = "GET"
HTTPMethodHead HTTPMethod = "HEAD"
HTTPMethodPost HTTPMethod = "POST"
HTTPMethodPut HTTPMethod = "PUT"
HTTPMethodDelete HTTPMethod = "DELETE"
HTTPMethodConnect HTTPMethod = "CONNECT"
HTTPMethodOptions HTTPMethod = "OPTIONS"
HTTPMethodTrace HTTPMethod = "TRACE"
HTTPMethodPatch HTTPMethod = "PATCH"
)
// HTTPRouteMatch defines the predicate used to match requests to a given
// action. Multiple match types are ANDed together, i.e. the match will
// evaluate to true only if all conditions are satisfied.
//
// For example, the match below will match a HTTP request only if its path
// starts with `/foo` AND it contains the `version: v1` header:
//
// ```
// match:
//
// path:
// value: "/foo"
// headers:
// - name: "version"
// value "v1"
//
// ```
// +k8s:deepcopy-gen=false
type HTTPRouteMatch = v1beta1.HTTPRouteMatch
// HTTPRouteFilter defines processing steps that must be completed during the
// request or response lifecycle. HTTPRouteFilters are meant as an extension
// point to express processing that may be done in Gateway implementations. Some
// examples include request or response modification, implementing
// authentication strategies, rate-limiting, and traffic shaping. API
// guarantee/conformance is defined based on the type of the filter.
// +k8s:deepcopy-gen=false
type HTTPRouteFilter = v1beta1.HTTPRouteFilter
// HTTPRouteFilterType identifies a type of HTTPRoute filter.
// +k8s:deepcopy-gen=false
type HTTPRouteFilterType = v1beta1.HTTPRouteFilterType
const (
// HTTPRouteFilterRequestHeaderModifier can be used to add or remove an HTTP
// header from an HTTP request before it is sent to the upstream target.
//
// Support in HTTPRouteRule: Core
//
// Support in HTTPBackendRef: Extended
HTTPRouteFilterRequestHeaderModifier HTTPRouteFilterType = "RequestHeaderModifier"
// HTTPRouteFilterRequestRedirect can be used to redirect a request to
// another location. This filter can also be used for HTTP to HTTPS
// redirects. This may not be used on the same Route rule or BackendRef as a
// URLRewrite filter.
//
// Support in HTTPRouteRule: Core
//
// Support in HTTPBackendRef: Extended
HTTPRouteFilterRequestRedirect HTTPRouteFilterType = "RequestRedirect"
// HTTPRouteFilterURLRewrite can be used to modify a request during
// forwarding. At most one of these filters may be used on a Route rule.
// This may not be used on the same Route rule or BackendRef as a
// RequestRedirect filter.
//
// Support in HTTPRouteRule: Extended
//
// Support in HTTPBackendRef: Extended
//
// <gateway:experimental>
HTTPRouteFilterURLRewrite HTTPRouteFilterType = "URLRewrite"
// HTTPRouteFilterRequestMirror can be used to mirror HTTP requests to a
// different backend. The responses from this backend MUST be ignored by
// the Gateway.
//
// Support in HTTPRouteRule: Extended
//
// Support in HTTPBackendRef: Extended
HTTPRouteFilterRequestMirror HTTPRouteFilterType = "RequestMirror"
// HTTPRouteFilterExtensionRef should be used for configuring custom
// HTTP filters.
//
// Support in HTTPRouteRule: Implementation-specific
//
// Support in HTTPBackendRef: Implementation-specific
HTTPRouteFilterExtensionRef HTTPRouteFilterType = "ExtensionRef"
)
// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
// +k8s:deepcopy-gen=false
type HTTPHeader = v1beta1.HTTPHeader
// HTTPHeaderFilter defines a filter that modifies the headers of an HTTP request
// or response.
// +k8s:deepcopy-gen=false
type HTTPHeaderFilter = v1beta1.HTTPHeaderFilter
// HTTPPathModifierType defines the type of path redirect or rewrite.
// +k8s:deepcopy-gen=false
type HTTPPathModifierType = v1beta1.HTTPPathModifierType
const (
// This type of modifier indicates that the full path will be replaced
// by the specified value.
FullPathHTTPPathModifier HTTPPathModifierType = "ReplaceFullPath"
// This type of modifier indicates that any prefix path matches will be
// replaced by the substitution value. For example, a path with a prefix
// match of "/foo" and a ReplacePrefixMatch substitution of "/bar" will have
// the "/foo" prefix replaced with "/bar" in matching requests.
//
// Note that this matches the behavior of the PathPrefix match type. This
// matches full path elements. A path element refers to the list of labels
// in the path split by the `/` separator. When specified, a trailing `/` is
// ignored. For example, the paths `/abc`, `/abc/`, and `/abc/def` would all
// match the prefix `/abc`, but the path `/abcd` would not.
PrefixMatchHTTPPathModifier HTTPPathModifierType = "ReplacePrefixMatch"
)
// HTTPPathModifier defines configuration for path modifiers.
// <gateway:experimental>
// +k8s:deepcopy-gen=false
type HTTPPathModifier = v1beta1.HTTPPathModifier
// HTTPRequestRedirect defines a filter that redirects a request. This filter
// MUST NOT be used on the same Route rule as a HTTPURLRewrite filter.
// +k8s:deepcopy-gen=false
type HTTPRequestRedirectFilter = v1beta1.HTTPRequestRedirectFilter
// HTTPURLRewriteFilter defines a filter that modifies a request during
// forwarding. At most one of these filters may be used on a Route rule. This
// MUST NOT be used on the same Route rule as a HTTPRequestRedirect filter.
//
// Support: Extended
//
// <gateway:experimental>
// +k8s:deepcopy-gen=false
type HTTPURLRewriteFilter = v1beta1.HTTPURLRewriteFilter
// HTTPRequestMirrorFilter defines configuration for the RequestMirror filter.
// +k8s:deepcopy-gen=false
type HTTPRequestMirrorFilter = v1beta1.HTTPRequestMirrorFilter
// HTTPBackendRef defines how a HTTPRoute should forward an HTTP request.
// +k8s:deepcopy-gen=false
type HTTPBackendRef = v1beta1.HTTPBackendRef
// HTTPRouteStatus defines the observed state of HTTPRoute.
// +k8s:deepcopy-gen=false
type HTTPRouteStatus = v1beta1.HTTPRouteStatus