Skip to content

Commit 0355305

Browse files
committed
Reducing common struct types
Signed-off-by: Dawid Nowak <[email protected]>
1 parent 4fbceaa commit 0355305

20 files changed

+4219
-94
lines changed

Cargo.lock

Lines changed: 402 additions & 89 deletions
Large diffs are not rendered by default.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["gateway-api", "gateway-api/examples", "xtask"]
2+
members = ["gateway-api", "gateway-api/examples", "xtask", "type-reducer"]
33
resolver = "2"
44

55
[workspace.package]

gateway-api/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,7 @@ uuid.workspace = true
3838
features = ["k8s-openapi/v1_32"]
3939

4040
[features]
41-
default = []
41+
default = ["processed"]
42+
standard = []
4243
experimental = []
44+
processed=[]

gateway-api/src/apis/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pub mod experimental;
22
pub mod standard;
3+
pub mod processed;
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// WARNING! generated file do not edit
2+
3+
#[allow(unused_imports)]
4+
mod prelude {
5+
pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition;
6+
pub use kube::CustomResource;
7+
pub use schemars::JsonSchema;
8+
pub use serde::{Deserialize, Serialize};
9+
pub use std::collections::BTreeMap;
10+
}
11+
use self::prelude::*;
12+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
13+
pub struct HeaderModifierRules {
14+
pub name: String,
15+
pub value: String,
16+
}
17+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
18+
pub struct Kind {
19+
#[serde(default, skip_serializing_if = "Option::is_none")]
20+
pub group: Option<String>,
21+
pub kind: String,
22+
}
23+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
24+
pub struct MirrorBackendRef {
25+
#[serde(default, skip_serializing_if = "Option::is_none")]
26+
pub group: Option<String>,
27+
#[serde(default, skip_serializing_if = "Option::is_none")]
28+
pub kind: Option<String>,
29+
pub name: String,
30+
#[serde(default, skip_serializing_if = "Option::is_none")]
31+
pub namespace: Option<String>,
32+
#[serde(default, skip_serializing_if = "Option::is_none")]
33+
pub port: Option<i32>,
34+
}
35+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
36+
pub struct RouteRef {
37+
#[serde(default, skip_serializing_if = "Option::is_none")]
38+
pub group: Option<String>,
39+
#[serde(default, skip_serializing_if = "Option::is_none")]
40+
pub kind: Option<String>,
41+
pub name: String,
42+
#[serde(default, skip_serializing_if = "Option::is_none")]
43+
pub namespace: Option<String>,
44+
#[serde(default, skip_serializing_if = "Option::is_none")]
45+
pub port: Option<i32>,
46+
#[serde(default, skip_serializing_if = "Option::is_none", rename = "sectionName")]
47+
pub section_name: Option<String>,
48+
}
49+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
50+
pub struct GatewayAddress {
51+
#[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
52+
pub r#type: Option<String>,
53+
pub value: String,
54+
}
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+
62+
63+
// Next attempt
64+
65+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
66+
pub struct FilterMirrorRouteRules {
67+
#[serde(rename = "backendRef")]
68+
pub backend_ref: MirrorBackendRef,
69+
}
70+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
71+
pub struct FilterHeaderRouteRules {
72+
#[serde(default, skip_serializing_if = "Option::is_none")]
73+
pub add: Option<Vec<HeaderModifierRules>>,
74+
#[serde(default, skip_serializing_if = "Option::is_none")]
75+
pub remove: Option<Vec<String>>,
76+
#[serde(default, skip_serializing_if = "Option::is_none")]
77+
pub set: Option<Vec<HeaderModifierRules>>,
78+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// WARNING! generated file do not edit
2+
3+
#[derive(Debug, PartialEq, Eq)]
4+
pub enum GatewayClassConditionType {
5+
Accepted,
6+
}
7+
impl std::fmt::Display for GatewayClassConditionType {
8+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9+
write!(f, "{:?}", self)
10+
}
11+
}
12+
#[derive(Debug, PartialEq, Eq)]
13+
pub enum GatewayClassConditionReason {
14+
Accepted,
15+
InvalidParameters,
16+
Pending,
17+
Unsupported,
18+
Waiting,
19+
}
20+
impl std::fmt::Display for GatewayClassConditionReason {
21+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
22+
write!(f, "{:?}", self)
23+
}
24+
}
25+
#[derive(Debug, PartialEq, Eq)]
26+
pub enum GatewayConditionType {
27+
Programmed,
28+
Accepted,
29+
Ready,
30+
}
31+
impl std::fmt::Display for GatewayConditionType {
32+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
33+
write!(f, "{:?}", self)
34+
}
35+
}
36+
#[derive(Debug, PartialEq, Eq)]
37+
pub enum GatewayConditionReason {
38+
Programmed,
39+
Invalid,
40+
NoResources,
41+
AddressNotAssigned,
42+
AddressNotUsable,
43+
Accepted,
44+
ListenersNotValid,
45+
Pending,
46+
UnsupportedAddress,
47+
InvalidParameters,
48+
Ready,
49+
ListenersNotReady,
50+
}
51+
impl std::fmt::Display for GatewayConditionReason {
52+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
53+
write!(f, "{:?}", self)
54+
}
55+
}
56+
#[derive(Debug, PartialEq, Eq)]
57+
pub enum ListenerConditionType {
58+
Conflicted,
59+
Accepted,
60+
ResolvedRefs,
61+
Programmed,
62+
Ready,
63+
}
64+
impl std::fmt::Display for ListenerConditionType {
65+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
66+
write!(f, "{:?}", self)
67+
}
68+
}
69+
#[derive(Debug, PartialEq, Eq)]
70+
pub enum ListenerConditionReason {
71+
HostnameConflict,
72+
ProtocolConflict,
73+
NoConflicts,
74+
Accepted,
75+
PortUnavailable,
76+
UnsupportedProtocol,
77+
ResolvedRefs,
78+
InvalidCertificateRef,
79+
InvalidRouteKinds,
80+
RefNotPermitted,
81+
Programmed,
82+
Invalid,
83+
Pending,
84+
Ready,
85+
}
86+
impl std::fmt::Display for ListenerConditionReason {
87+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
88+
write!(f, "{:?}", self)
89+
}
90+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// WARNING! generated file do not edit
2+
3+
use super::httproutes::{
4+
HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType,
5+
HTTPRouteRulesBackendRefsFiltersType,
6+
HTTPRouteRulesBackendRefsFiltersUrlRewritePathType,
7+
HTTPRouteRulesFiltersRequestRedirectPathType, HTTPRouteRulesFiltersType,
8+
HTTPRouteRulesFiltersUrlRewritePathType,
9+
};
10+
use super::grpcroutes::{GRPCRouteRulesBackendRefsFiltersType, GRPCRouteRulesFiltersType};
11+
impl Default for GRPCRouteRulesBackendRefsFiltersType {
12+
fn default() -> Self {
13+
GRPCRouteRulesBackendRefsFiltersType::RequestHeaderModifier
14+
}
15+
}
16+
impl Default for GRPCRouteRulesFiltersType {
17+
fn default() -> Self {
18+
GRPCRouteRulesFiltersType::RequestHeaderModifier
19+
}
20+
}
21+
impl Default for HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType {
22+
fn default() -> Self {
23+
HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType::ReplaceFullPath
24+
}
25+
}
26+
impl Default for HTTPRouteRulesBackendRefsFiltersType {
27+
fn default() -> Self {
28+
HTTPRouteRulesBackendRefsFiltersType::RequestHeaderModifier
29+
}
30+
}
31+
impl Default for HTTPRouteRulesBackendRefsFiltersUrlRewritePathType {
32+
fn default() -> Self {
33+
HTTPRouteRulesBackendRefsFiltersUrlRewritePathType::ReplaceFullPath
34+
}
35+
}
36+
impl Default for HTTPRouteRulesFiltersRequestRedirectPathType {
37+
fn default() -> Self {
38+
HTTPRouteRulesFiltersRequestRedirectPathType::ReplaceFullPath
39+
}
40+
}
41+
impl Default for HTTPRouteRulesFiltersType {
42+
fn default() -> Self {
43+
HTTPRouteRulesFiltersType::RequestHeaderModifier
44+
}
45+
}
46+
impl Default for HTTPRouteRulesFiltersUrlRewritePathType {
47+
fn default() -> Self {
48+
HTTPRouteRulesFiltersUrlRewritePathType::ReplaceFullPath
49+
}
50+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
// WARNING! generated file do not edit
2+
3+
#[allow(unused_imports)]
4+
mod prelude {
5+
pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition;
6+
pub use kube::CustomResource;
7+
pub use schemars::JsonSchema;
8+
pub use serde::{Deserialize, Serialize};
9+
}
10+
use self::prelude::*;
11+
/// Spec defines the desired state of GatewayClass.
12+
#[derive(
13+
CustomResource,
14+
Serialize,
15+
Deserialize,
16+
Clone,
17+
Debug,
18+
JsonSchema,
19+
Default,
20+
PartialEq
21+
)]
22+
#[kube(
23+
group = "gateway.networking.k8s.io",
24+
version = "v1",
25+
kind = "GatewayClass",
26+
plural = "gatewayclasses"
27+
)]
28+
#[kube(status = "GatewayClassStatus")]
29+
#[kube(derive = "Default")]
30+
#[kube(derive = "PartialEq")]
31+
pub struct GatewayClassSpec {
32+
/// ControllerName is the name of the controller that is managing Gateways of
33+
/// this class. The value of this field MUST be a domain prefixed path.
34+
///
35+
/// Example: "example.net/gateway-controller".
36+
///
37+
/// This field is not mutable and cannot be empty.
38+
///
39+
/// Support: Core
40+
#[serde(rename = "controllerName")]
41+
pub controller_name: String,
42+
/// Description helps describe a GatewayClass with more details.
43+
#[serde(default, skip_serializing_if = "Option::is_none")]
44+
pub description: Option<String>,
45+
/// ParametersRef is a reference to a resource that contains the configuration
46+
/// parameters corresponding to the GatewayClass. This is optional if the
47+
/// controller does not require any additional configuration.
48+
///
49+
/// ParametersRef can reference a standard Kubernetes resource, i.e. ConfigMap,
50+
/// or an implementation-specific custom resource. The resource can be
51+
/// cluster-scoped or namespace-scoped.
52+
///
53+
/// If the referent cannot be found, refers to an unsupported kind, or when
54+
/// the data within that resource is malformed, the GatewayClass SHOULD be
55+
/// rejected with the "Accepted" status condition set to "False" and an
56+
/// "InvalidParameters" reason.
57+
///
58+
/// A Gateway for this GatewayClass may provide its own `parametersRef`. When both are specified,
59+
/// the merging behavior is implementation specific.
60+
/// It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway.
61+
///
62+
/// Support: Implementation-specific
63+
#[serde(default, skip_serializing_if = "Option::is_none", rename = "parametersRef")]
64+
pub parameters_ref: Option<GatewayClassParametersRef>,
65+
}
66+
/// ParametersRef is a reference to a resource that contains the configuration
67+
/// parameters corresponding to the GatewayClass. This is optional if the
68+
/// controller does not require any additional configuration.
69+
///
70+
/// ParametersRef can reference a standard Kubernetes resource, i.e. ConfigMap,
71+
/// or an implementation-specific custom resource. The resource can be
72+
/// cluster-scoped or namespace-scoped.
73+
///
74+
/// If the referent cannot be found, refers to an unsupported kind, or when
75+
/// the data within that resource is malformed, the GatewayClass SHOULD be
76+
/// rejected with the "Accepted" status condition set to "False" and an
77+
/// "InvalidParameters" reason.
78+
///
79+
/// A Gateway for this GatewayClass may provide its own `parametersRef`. When both are specified,
80+
/// the merging behavior is implementation specific.
81+
/// It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway.
82+
///
83+
/// Support: Implementation-specific
84+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
85+
pub struct GatewayClassParametersRef {
86+
/// Group is the group of the referent.
87+
pub group: String,
88+
/// Kind is kind of the referent.
89+
pub kind: String,
90+
/// Name is the name of the referent.
91+
pub name: String,
92+
/// Namespace is the namespace of the referent.
93+
/// This field is required when referring to a Namespace-scoped resource and
94+
/// MUST be unset when referring to a Cluster-scoped resource.
95+
#[serde(default, skip_serializing_if = "Option::is_none")]
96+
pub namespace: Option<String>,
97+
}
98+
/// Status defines the current state of GatewayClass.
99+
///
100+
/// Implementations MUST populate status on all GatewayClass resources which
101+
/// specify their controller name.
102+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
103+
pub struct GatewayClassStatus {
104+
/// Conditions is the current status from the controller for
105+
/// this GatewayClass.
106+
///
107+
/// Controllers should prefer to publish conditions using values
108+
/// of GatewayClassConditionType for the type of each Condition.
109+
#[serde(default, skip_serializing_if = "Option::is_none")]
110+
pub conditions: Option<Vec<Condition>>,
111+
}

0 commit comments

Comments
 (0)