Skip to content

Commit a974d67

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

24 files changed

+630
-443
lines changed

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

Lines changed: 65 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct HTTPHeader {
1515
pub value: String,
1616
}
1717
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
18-
pub struct MirrorBackendRef {
18+
pub struct RouteRef {
1919
#[serde(default, skip_serializing_if = "Option::is_none")]
2020
pub group: Option<String>,
2121
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -25,21 +25,11 @@ pub struct MirrorBackendRef {
2525
pub namespace: Option<String>,
2626
#[serde(default, skip_serializing_if = "Option::is_none")]
2727
pub port: Option<i32>,
28+
#[serde(default, skip_serializing_if = "Option::is_none", rename = "sectionName")]
29+
pub section_name: Option<String>,
2830
}
2931
#[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)]
42-
pub struct RouteRef {
32+
pub struct RequestMirrorRef {
4333
#[serde(default, skip_serializing_if = "Option::is_none")]
4434
pub group: Option<String>,
4535
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -49,29 +39,32 @@ pub struct RouteRef {
4939
pub namespace: Option<String>,
5040
#[serde(default, skip_serializing_if = "Option::is_none")]
5141
pub port: Option<i32>,
52-
#[serde(default, skip_serializing_if = "Option::is_none", rename = "sectionName")]
53-
pub section_name: Option<String>,
5442
}
5543
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
56-
pub struct ExtensionBackendRef {
44+
pub struct Kind {
45+
#[serde(default, skip_serializing_if = "Option::is_none")]
46+
pub group: Option<String>,
47+
pub kind: String,
48+
}
49+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
50+
pub struct GatewayInfrastructureParametersRef {
5751
pub group: String,
5852
pub kind: String,
5953
pub name: String,
6054
}
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,
55+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
56+
pub struct GatewayAddress {
57+
#[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
58+
pub r#type: Option<String>,
59+
pub value: String,
6760
}
6861
/// Path defines parameters used to modify the path of the incoming request.
6962
/// The modified path is then used to construct the `Location` header. When
7063
/// empty, the request path is used as-is.
7164
///
7265
/// Support: Extended
7366
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
74-
pub enum HTTPPathType {
67+
pub enum RequestOperationType {
7568
ReplaceFullPath,
7669
ReplacePrefixMatch,
7770
}
@@ -86,57 +79,60 @@ pub enum RedirectStatusCode {
8679
#[serde(rename = "302")]
8780
r#_302,
8881
}
89-
/// HTTPRouteFilter defines processing steps that must be completed during the
90-
/// request or response lifecycle. HTTPRouteFilters are meant as an extension
82+
/// GRPCHeaderMatch describes how to select a gRPC route by matching gRPC request
83+
/// headers.
84+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
85+
pub enum HeaderMatchType {
86+
Exact,
87+
RegularExpression,
88+
}
89+
/// GRPCRouteFilter defines processing steps that must be completed during the
90+
/// request or response lifecycle. GRPCRouteFilters are meant as an extension
9191
/// point to express processing that may be done in Gateway implementations. Some
9292
/// examples include request or response modification, implementing
9393
/// authentication strategies, rate-limiting, and traffic shaping. API
9494
/// guarantee/conformance is defined based on the type of the filter.
9595
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
96-
pub enum HTTPFilterType {
97-
RequestHeaderModifier,
96+
pub enum GRPCFilterType {
9897
ResponseHeaderModifier,
98+
RequestHeaderModifier,
9999
RequestMirror,
100-
RequestRedirect,
101-
#[serde(rename = "URLRewrite")]
102-
UrlRewrite,
103100
ExtensionRef,
104101
}
105102
/// RequestRedirect defines a schema for a filter that responds to the
106103
/// request with an HTTP redirection.
107104
///
108105
/// Support: Core
109106
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
110-
pub enum HTTPRedirectScheme {
107+
pub enum RequestRedirectScheme {
111108
#[serde(rename = "http")]
112109
Http,
113110
#[serde(rename = "https")]
114111
Https,
115112
}
116-
/// GRPCRouteFilter defines processing steps that must be completed during the
117-
/// request or response lifecycle. GRPCRouteFilters are meant as an extension
113+
/// HTTPRouteFilter defines processing steps that must be completed during the
114+
/// request or response lifecycle. HTTPRouteFilters are meant as an extension
118115
/// point to express processing that may be done in Gateway implementations. Some
119116
/// examples include request or response modification, implementing
120117
/// authentication strategies, rate-limiting, and traffic shaping. API
121118
/// guarantee/conformance is defined based on the type of the filter.
122119
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
123-
pub enum GRPCFilterType {
124-
ResponseHeaderModifier,
120+
pub enum HTTPFilterType {
125121
RequestHeaderModifier,
122+
ResponseHeaderModifier,
126123
RequestMirror,
124+
RequestRedirect,
125+
#[serde(rename = "URLRewrite")]
126+
UrlRewrite,
127127
ExtensionRef,
128128
}
129129
#[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,
130+
pub struct RequestMirror {
131+
#[serde(rename = "backendRef")]
132+
pub backend_ref: RequestMirrorRef,
137133
}
138134
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
139-
pub struct HTTPPathModifier {
135+
pub struct RequestRedirectPath {
140136
#[serde(
141137
default,
142138
skip_serializing_if = "Option::is_none",
@@ -150,7 +146,14 @@ pub struct HTTPPathModifier {
150146
)]
151147
pub replace_prefix_match: Option<String>,
152148
#[serde(rename = "type")]
153-
pub r#type: HTTPPathType,
149+
pub r#type: RequestOperationType,
150+
}
151+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
152+
pub struct MatchingHeaders {
153+
pub name: String,
154+
#[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
155+
pub r#type: Option<HeaderMatchType>,
156+
pub value: String,
154157
}
155158
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
156159
pub struct HeaderModifier {
@@ -162,81 +165,39 @@ pub struct HeaderModifier {
162165
pub set: Option<Vec<HTTPHeader>>,
163166
}
164167
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
165-
pub struct RequestMirrorModifier {
166-
#[serde(rename = "backendRef")]
167-
pub backend_ref: MirrorBackendRef,
168+
pub struct ParentRouteStatus {
169+
#[serde(default, skip_serializing_if = "Option::is_none")]
170+
pub conditions: Option<Vec<Condition>>,
171+
#[serde(rename = "controllerName")]
172+
pub controller_name: String,
173+
#[serde(rename = "parentRef")]
174+
pub parent_ref: RouteRef,
168175
}
169176
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
170-
pub struct HTTPRequestRewrite {
171-
#[serde(default, skip_serializing_if = "Option::is_none")]
172-
pub hostname: Option<String>,
173-
#[serde(default, skip_serializing_if = "Option::is_none")]
174-
pub path: Option<HTTPPathModifier>,
177+
pub struct RouteStatus {
178+
pub parents: Vec<ParentRouteStatus>,
175179
}
176180
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
177-
pub struct HTTPRequestRedirect {
181+
pub struct HTTPRouteRequestRedirect {
178182
#[serde(default, skip_serializing_if = "Option::is_none")]
179183
pub hostname: Option<String>,
180184
#[serde(default, skip_serializing_if = "Option::is_none")]
181-
pub path: Option<HTTPPathModifier>,
185+
pub path: Option<RequestRedirectPath>,
182186
#[serde(default, skip_serializing_if = "Option::is_none")]
183187
pub port: Option<i32>,
184188
#[serde(default, skip_serializing_if = "Option::is_none")]
185-
pub scheme: Option<HTTPRedirectScheme>,
189+
pub scheme: Option<RequestRedirectScheme>,
186190
#[serde(default, skip_serializing_if = "Option::is_none", rename = "statusCode")]
187191
pub status_code: Option<i64>,
188192
}
189193
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
190-
pub struct GRPCRouteFilter {
191-
#[serde(default, skip_serializing_if = "Option::is_none", rename = "extensionRef")]
192-
pub extension_ref: Option<ExtensionBackendRef>,
193-
#[serde(
194-
default,
195-
skip_serializing_if = "Option::is_none",
196-
rename = "requestHeaderModifier"
197-
)]
198-
pub request_header_modifier: Option<HeaderModifier>,
199-
#[serde(default, skip_serializing_if = "Option::is_none", rename = "requestMirror")]
200-
pub request_mirror: Option<RequestMirrorModifier>,
201-
#[serde(
202-
default,
203-
skip_serializing_if = "Option::is_none",
204-
rename = "responseHeaderModifier"
205-
)]
206-
pub response_header_modifier: Option<HeaderModifier>,
207-
#[serde(rename = "type")]
208-
pub r#type: GRPCFilterType,
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>,
209199
}
210200

211201

212202
// Next attempt
213203

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)]

0 commit comments

Comments
 (0)