Skip to content

Commit 9958589

Browse files
committed
Removal of intermediate dervied types, fixing bugs
Signed-off-by: Dawid Nowak <[email protected]>
1 parent 359424b commit 9958589

25 files changed

+501
-455
lines changed

gateway-api/src/apis/processed/common_types.rs

Lines changed: 96 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,30 @@ mod prelude {
1010
}
1111
use self::prelude::*;
1212
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
13+
pub struct GatewayAddress {
14+
#[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
15+
pub r#type: Option<String>,
16+
pub value: String,
17+
}
18+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
19+
pub struct GatewayInfrastructureParametersRef {
20+
pub group: String,
21+
pub kind: String,
22+
pub name: String,
23+
}
24+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
25+
pub struct Kind {
26+
#[serde(default, skip_serializing_if = "Option::is_none")]
27+
pub group: Option<String>,
28+
pub kind: String,
29+
}
30+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1331
pub struct HTTPHeader {
1432
pub name: String,
1533
pub value: String,
1634
}
1735
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
18-
pub struct MirrorBackendRef {
36+
pub struct RequestMirrorRef {
1937
#[serde(default, skip_serializing_if = "Option::is_none")]
2038
pub group: Option<String>,
2139
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -27,18 +45,6 @@ pub struct MirrorBackendRef {
2745
pub port: Option<i32>,
2846
}
2947
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
30-
pub struct Kind {
31-
#[serde(default, skip_serializing_if = "Option::is_none")]
32-
pub group: Option<String>,
33-
pub kind: String,
34-
}
35-
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
36-
pub struct GatewayAddress {
37-
#[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
38-
pub r#type: Option<String>,
39-
pub value: String,
40-
}
41-
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
4248
pub struct RouteRef {
4349
#[serde(default, skip_serializing_if = "Option::is_none")]
4450
pub group: Option<String>,
@@ -52,40 +58,6 @@ pub struct RouteRef {
5258
#[serde(default, skip_serializing_if = "Option::is_none", rename = "sectionName")]
5359
pub section_name: Option<String>,
5460
}
55-
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
56-
pub struct ExtensionBackendRef {
57-
pub group: String,
58-
pub kind: String,
59-
pub name: String,
60-
}
61-
/// GRPCHeaderMatch describes how to select a gRPC route by matching gRPC request
62-
/// headers.
63-
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
64-
pub enum HeaderMatchesType {
65-
Exact,
66-
RegularExpression,
67-
}
68-
/// Path defines parameters used to modify the path of the incoming request.
69-
/// The modified path is then used to construct the `Location` header. When
70-
/// empty, the request path is used as-is.
71-
///
72-
/// Support: Extended
73-
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
74-
pub enum HTTPPathType {
75-
ReplaceFullPath,
76-
ReplacePrefixMatch,
77-
}
78-
/// RequestRedirect defines a schema for a filter that responds to the
79-
/// request with an HTTP redirection.
80-
///
81-
/// Support: Core
82-
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
83-
pub enum RedirectStatusCode {
84-
#[serde(rename = "301")]
85-
r#_301,
86-
#[serde(rename = "302")]
87-
r#_302,
88-
}
8961
/// HTTPRouteFilter defines processing steps that must be completed during the
9062
/// request or response lifecycle. HTTPRouteFilters are meant as an extension
9163
/// point to express processing that may be done in Gateway implementations. Some
@@ -102,17 +74,6 @@ pub enum HTTPFilterType {
10274
UrlRewrite,
10375
ExtensionRef,
10476
}
105-
/// RequestRedirect defines a schema for a filter that responds to the
106-
/// request with an HTTP redirection.
107-
///
108-
/// Support: Core
109-
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
110-
pub enum HTTPRedirectScheme {
111-
#[serde(rename = "http")]
112-
Http,
113-
#[serde(rename = "https")]
114-
Https,
115-
}
11677
/// GRPCRouteFilter defines processing steps that must be completed during the
11778
/// request or response lifecycle. GRPCRouteFilters are meant as an extension
11879
/// point to express processing that may be done in Gateway implementations. Some
@@ -126,17 +87,47 @@ pub enum GRPCFilterType {
12687
RequestMirror,
12788
ExtensionRef,
12889
}
129-
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
130-
pub struct ParentsRouteStatus {
131-
#[serde(default, skip_serializing_if = "Option::is_none")]
132-
pub conditions: Option<Vec<Condition>>,
133-
#[serde(rename = "controllerName")]
134-
pub controller_name: String,
135-
#[serde(rename = "parentRef")]
136-
pub parent_ref: RouteRef,
90+
/// RequestRedirect defines a schema for a filter that responds to the
91+
/// request with an HTTP redirection.
92+
///
93+
/// Support: Core
94+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
95+
pub enum RequestRedirectScheme {
96+
#[serde(rename = "http")]
97+
Http,
98+
#[serde(rename = "https")]
99+
Https,
100+
}
101+
/// GRPCHeaderMatch describes how to select a gRPC route by matching gRPC request
102+
/// headers.
103+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
104+
pub enum HeaderMatchType {
105+
Exact,
106+
RegularExpression,
107+
}
108+
/// Path defines parameters used to modify the path of the incoming request.
109+
/// The modified path is then used to construct the `Location` header. When
110+
/// empty, the request path is used as-is.
111+
///
112+
/// Support: Extended
113+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
114+
pub enum RequestOperationType {
115+
ReplaceFullPath,
116+
ReplacePrefixMatch,
117+
}
118+
/// RequestRedirect defines a schema for a filter that responds to the
119+
/// request with an HTTP redirection.
120+
///
121+
/// Support: Core
122+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
123+
pub enum RedirectStatusCode {
124+
#[serde(rename = "301")]
125+
r#_301,
126+
#[serde(rename = "302")]
127+
r#_302,
137128
}
138129
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
139-
pub struct HTTPPathModifier {
130+
pub struct RequestRedirectPath {
140131
#[serde(
141132
default,
142133
skip_serializing_if = "Option::is_none",
@@ -150,54 +141,74 @@ pub struct HTTPPathModifier {
150141
)]
151142
pub replace_prefix_match: Option<String>,
152143
#[serde(rename = "type")]
153-
pub r#type: HTTPPathType,
144+
pub r#type: RequestOperationType,
154145
}
155146
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
156-
pub struct HeaderModifier {
157-
#[serde(default, skip_serializing_if = "Option::is_none")]
158-
pub add: Option<Vec<HTTPHeader>>,
159-
#[serde(default, skip_serializing_if = "Option::is_none")]
160-
pub remove: Option<Vec<String>>,
161-
#[serde(default, skip_serializing_if = "Option::is_none")]
162-
pub set: Option<Vec<HTTPHeader>>,
147+
pub struct MatchingHeaders {
148+
pub name: String,
149+
#[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
150+
pub r#type: Option<HeaderMatchType>,
151+
pub value: String,
163152
}
164153
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
165-
pub struct RequestMirrorModifier {
154+
pub struct RequestMirror {
166155
#[serde(rename = "backendRef")]
167-
pub backend_ref: MirrorBackendRef,
156+
pub backend_ref: RequestMirrorRef,
168157
}
169158
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
170-
pub struct HTTPRequestRewrite {
159+
pub struct ParentRouteStatus {
171160
#[serde(default, skip_serializing_if = "Option::is_none")]
172-
pub hostname: Option<String>,
161+
pub conditions: Option<Vec<Condition>>,
162+
#[serde(rename = "controllerName")]
163+
pub controller_name: String,
164+
#[serde(rename = "parentRef")]
165+
pub parent_ref: RouteRef,
166+
}
167+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
168+
pub struct HeaderModifier {
173169
#[serde(default, skip_serializing_if = "Option::is_none")]
174-
pub path: Option<HTTPPathModifier>,
170+
pub add: Option<Vec<HTTPHeader>>,
171+
#[serde(default, skip_serializing_if = "Option::is_none")]
172+
pub remove: Option<Vec<String>>,
173+
#[serde(default, skip_serializing_if = "Option::is_none")]
174+
pub set: Option<Vec<HTTPHeader>>,
175175
}
176176
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
177-
pub struct HTTPRequestRedirect {
177+
pub struct HTTPRouteRequestRedirect {
178178
#[serde(default, skip_serializing_if = "Option::is_none")]
179179
pub hostname: Option<String>,
180180
#[serde(default, skip_serializing_if = "Option::is_none")]
181-
pub path: Option<HTTPPathModifier>,
181+
pub path: Option<RequestRedirectPath>,
182182
#[serde(default, skip_serializing_if = "Option::is_none")]
183183
pub port: Option<i32>,
184184
#[serde(default, skip_serializing_if = "Option::is_none")]
185-
pub scheme: Option<HTTPRedirectScheme>,
185+
pub scheme: Option<RequestRedirectScheme>,
186186
#[serde(default, skip_serializing_if = "Option::is_none", rename = "statusCode")]
187187
pub status_code: Option<i64>,
188188
}
189189
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
190+
pub struct RouteStatus {
191+
pub parents: Vec<ParentRouteStatus>,
192+
}
193+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
194+
pub struct HTTPRouteUrlRewrite {
195+
#[serde(default, skip_serializing_if = "Option::is_none")]
196+
pub hostname: Option<String>,
197+
#[serde(default, skip_serializing_if = "Option::is_none")]
198+
pub path: Option<RequestRedirectPath>,
199+
}
200+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
190201
pub struct GRPCRouteFilter {
191202
#[serde(default, skip_serializing_if = "Option::is_none", rename = "extensionRef")]
192-
pub extension_ref: Option<ExtensionBackendRef>,
203+
pub extension_ref: Option<GatewayInfrastructureParametersRef>,
193204
#[serde(
194205
default,
195206
skip_serializing_if = "Option::is_none",
196207
rename = "requestHeaderModifier"
197208
)]
198209
pub request_header_modifier: Option<HeaderModifier>,
199210
#[serde(default, skip_serializing_if = "Option::is_none", rename = "requestMirror")]
200-
pub request_mirror: Option<RequestMirrorModifier>,
211+
pub request_mirror: Option<RequestMirror>,
201212
#[serde(
202213
default,
203214
skip_serializing_if = "Option::is_none",
@@ -211,32 +222,3 @@ pub struct GRPCRouteFilter {
211222

212223
// Next attempt
213224

214-
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
215-
pub struct HTTPRouteFilter {
216-
#[serde(default, skip_serializing_if = "Option::is_none", rename = "extensionRef")]
217-
pub extension_ref: Option<ExtensionBackendRef>,
218-
#[serde(
219-
default,
220-
skip_serializing_if = "Option::is_none",
221-
rename = "requestHeaderModifier"
222-
)]
223-
pub request_header_modifier: Option<HeaderModifier>,
224-
#[serde(default, skip_serializing_if = "Option::is_none", rename = "requestMirror")]
225-
pub request_mirror: Option<RequestMirrorModifier>,
226-
#[serde(
227-
default,
228-
skip_serializing_if = "Option::is_none",
229-
rename = "requestRedirect"
230-
)]
231-
pub request_redirect: Option<HTTPRequestRedirect>,
232-
#[serde(
233-
default,
234-
skip_serializing_if = "Option::is_none",
235-
rename = "responseHeaderModifier"
236-
)]
237-
pub response_header_modifier: Option<HeaderModifier>,
238-
#[serde(rename = "type")]
239-
pub r#type: HTTPFilterType,
240-
#[serde(default, skip_serializing_if = "Option::is_none", rename = "urlRewrite")]
241-
pub url_rewrite: Option<HTTPRequestRewrite>,
242-
}

gateway-api/src/apis/processed/enum_defaults.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ impl Default for HTTPFilterType {
1313
}
1414
}
1515

16-
impl Default for HTTPPathType {
16+
impl Default for RequestOperationType {
1717
fn default() -> Self {
18-
HTTPPathType::ReplaceFullPath
18+
RequestOperationType::ReplaceFullPath
1919
}
2020
}

gateway-api/src/apis/processed/gateways.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -226,26 +226,6 @@ pub struct GatewayInfrastructure {
226226
#[serde(default, skip_serializing_if = "Option::is_none", rename = "parametersRef")]
227227
pub parameters_ref: Option<GatewayInfrastructureParametersRef>,
228228
}
229-
/// ParametersRef is a reference to a resource that contains the configuration
230-
/// parameters corresponding to the Gateway. This is optional if the
231-
/// controller does not require any additional configuration.
232-
///
233-
/// This follows the same semantics as GatewayClass's `parametersRef`, but on a per-Gateway basis
234-
///
235-
/// The Gateway's GatewayClass may provide its own `parametersRef`. When both are specified,
236-
/// the merging behavior is implementation specific.
237-
/// It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway.
238-
///
239-
/// Support: Implementation-specific
240-
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
241-
pub struct GatewayInfrastructureParametersRef {
242-
/// Group is the group of the referent.
243-
pub group: String,
244-
/// Kind is kind of the referent.
245-
pub kind: String,
246-
/// Name is the name of the referent.
247-
pub name: String,
248-
}
249229
/// Listener embodies the concept of a logical endpoint where a Gateway accepts
250230
/// network connections.
251231
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]

gateway-api/src/apis/processed/grpcroutes.rs

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use self::prelude::*;
2727
plural = "grpcroutes"
2828
)]
2929
#[kube(namespaced)]
30-
#[kube(status = "GRPCRouteStatus")]
30+
#[kube(status = "RouteStatus")]
3131
#[kube(derive = "Default")]
3232
#[kube(derive = "PartialEq")]
3333
pub struct GRPCRouteSpec {
@@ -373,30 +373,12 @@ pub struct GRPCRouteRulesMatches {
373373
/// ANDed together, meaning, a request MUST match all the specified headers
374374
/// to select the route.
375375
#[serde(default, skip_serializing_if = "Option::is_none")]
376-
pub headers: Option<Vec<GRPCRouteRulesMatchesHeaders>>,
376+
pub headers: Option<Vec<MatchingHeaders>>,
377377
/// Method specifies a gRPC request service/method matcher. If this field is
378378
/// not specified, all services and methods will match.
379379
#[serde(default, skip_serializing_if = "Option::is_none")]
380380
pub method: Option<GRPCRouteRulesMatchesMethod>,
381381
}
382-
/// GRPCHeaderMatch describes how to select a gRPC route by matching gRPC request
383-
/// headers.
384-
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
385-
pub struct GRPCRouteRulesMatchesHeaders {
386-
/// Name is the name of the gRPC Header to be matched.
387-
///
388-
/// If multiple entries specify equivalent header names, only the first
389-
/// entry with an equivalent name MUST be considered for a match. Subsequent
390-
/// entries with an equivalent header name MUST be ignored. Due to the
391-
/// case-insensitivity of header names, "foo" and "Foo" are considered
392-
/// equivalent.
393-
pub name: String,
394-
/// Type specifies how to match against the value of the header.
395-
#[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
396-
pub r#type: Option<HeaderMatchesType>,
397-
/// Value is the value of the gRPC Header to be matched.
398-
pub value: String,
399-
}
400382
/// Method specifies a gRPC request service/method matcher. If this field is
401383
/// not specified, all services and methods will match.
402384
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
@@ -420,24 +402,5 @@ pub struct GRPCRouteRulesMatchesMethod {
420402
///
421403
/// Support: Implementation-specific (RegularExpression)
422404
#[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
423-
pub r#type: Option<HeaderMatchesType>,
424-
}
425-
/// Status defines the current state of GRPCRoute.
426-
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
427-
pub struct GRPCRouteStatus {
428-
/// Parents is a list of parent resources (usually Gateways) that are
429-
/// associated with the route, and the status of the route with respect to
430-
/// each parent. When this route attaches to a parent, the controller that
431-
/// manages the parent must add an entry to this list when the controller
432-
/// first sees the route and should update the entry as appropriate when the
433-
/// route or gateway is modified.
434-
///
435-
/// Note that parent references that cannot be resolved by an implementation
436-
/// of this API will not be added to this list. Implementations of this API
437-
/// can only populate Route status for the Gateways/parent resources they are
438-
/// responsible for.
439-
///
440-
/// A maximum of 32 Gateways will be represented in this list. An empty list
441-
/// means the route has not been attached to any Gateway.
442-
pub parents: Vec<ParentsRouteStatus>,
405+
pub r#type: Option<HeaderMatchType>,
443406
}

0 commit comments

Comments
 (0)