Skip to content

Commit b1dd048

Browse files
committed
Pulling standard APIs up and hiding experimental apis behind a feature flag
Signed-off-by: Dawid Nowak <[email protected]>
1 parent ca4e494 commit b1dd048

25 files changed

+82
-51
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ name = "gateway-api"
331331
version = "0.15.0"
332332
dependencies = [
333333
"anyhow",
334+
"cfg-if",
334335
"delegate",
335336
"hyper-util",
336337
"k8s-openapi",

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ tower = { version = "0.5.2", features = ["limit"] }
2525
tracing = "0.1.41"
2626
tracing-subscriber = "0.3.19"
2727
uuid = { version = "1.16.0", features = ["v4", "fast-rng"] }
28+
cfg-if = "1.0"
29+

gateway-api/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ schemars.workspace = true
2323
serde_json.workspace = true
2424
serde.workspace = true
2525
serde_yaml.workspace = true
26+
cfg-if.workspace = true
2627

2728
[dev-dependencies]
2829
k8s-openapi = { workspace = true, features = [ "v1_32", "schemars" ] }
@@ -36,3 +37,7 @@ uuid.workspace = true
3637

3738
[package.metadata.docs.rs]
3839
features = [ "k8s-openapi/v1_32" ]
40+
41+
[features]
42+
default = []
43+
experimental = []

gateway-api/src/apis/mod.rs

Lines changed: 0 additions & 2 deletions
This file was deleted.

gateway-api/src/apis/experimental/gatewayclasses.rs renamed to gateway-api/src/experimental/gatewayclasses.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// WARNING: generated by kopium - manual changes will be overwritten
22
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f -
3-
// kopium version: 0.21.0
3+
// kopium version: 0.21.1
44

55
#[allow(unused_imports)]
66
mod prelude {

gateway-api/src/apis/experimental/gateways.rs renamed to gateway-api/src/experimental/gateways.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// WARNING: generated by kopium - manual changes will be overwritten
22
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f -
3-
// kopium version: 0.21.0
3+
// kopium version: 0.21.1
44

55
#[allow(unused_imports)]
66
mod prelude {

gateway-api/src/apis/experimental/grpcroutes.rs renamed to gateway-api/src/experimental/grpcroutes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// WARNING: generated by kopium - manual changes will be overwritten
22
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f -
3-
// kopium version: 0.21.0
3+
// kopium version: 0.21.1
44

55
#[allow(unused_imports)]
66
mod prelude {
@@ -351,7 +351,7 @@ pub struct GRPCRouteRules {
351351
///
352352
/// For example, take the following matches configuration:
353353
///
354-
/// ```
354+
/// ```text
355355
/// matches:
356356
/// - method:
357357
/// service: foo.bar
@@ -1413,7 +1413,7 @@ pub enum GRPCRouteRulesFiltersType {
14131413
/// For example, the match below will match a gRPC request only if its service
14141414
/// is `foo` AND it contains the `version: v1` header:
14151415
///
1416-
/// ```
1416+
/// ```text
14171417
/// matches:
14181418
/// - method:
14191419
/// type: Exact

gateway-api/src/apis/experimental/httproutes.rs renamed to gateway-api/src/experimental/httproutes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// WARNING: generated by kopium - manual changes will be overwritten
22
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f -
3-
// kopium version: 0.21.0
3+
// kopium version: 0.21.1
44

55
#[allow(unused_imports)]
66
mod prelude {
@@ -373,7 +373,7 @@ pub struct HTTPRouteRules {
373373
///
374374
/// For example, take the following matches configuration:
375375
///
376-
/// ```
376+
/// ```text
377377
/// matches:
378378
/// - path:
379379
/// value: "/foo"
@@ -1986,7 +1986,7 @@ pub enum HTTPRouteRulesFiltersUrlRewritePathType {
19861986
/// For example, the match below will match a HTTP request only if its path
19871987
/// starts with `/foo` AND it contains the `version: v1` header:
19881988
///
1989-
/// ```
1989+
/// ```text
19901990
/// match:
19911991
///
19921992
/// path:
@@ -2077,7 +2077,7 @@ pub enum HTTPRouteRulesMatchesHeadersType {
20772077
/// For example, the match below will match a HTTP request only if its path
20782078
/// starts with `/foo` AND it contains the `version: v1` header:
20792079
///
2080-
/// ```
2080+
/// ```text
20812081
/// match:
20822082
///
20832083
/// path:

gateway-api/src/apis/experimental/referencegrants.rs renamed to gateway-api/src/experimental/referencegrants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// WARNING: generated by kopium - manual changes will be overwritten
22
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f -
3-
// kopium version: 0.21.0
3+
// kopium version: 0.21.1
44

55
#[allow(unused_imports)]
66
mod prelude {

gateway-api/src/apis/experimental/tcproutes.rs renamed to gateway-api/src/experimental/tcproutes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// WARNING: generated by kopium - manual changes will be overwritten
22
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f -
3-
// kopium version: 0.21.0
3+
// kopium version: 0.21.1
44

55
#[allow(unused_imports)]
66
mod prelude {

gateway-api/src/apis/experimental/tlsroutes.rs renamed to gateway-api/src/experimental/tlsroutes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// WARNING: generated by kopium - manual changes will be overwritten
22
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f -
3-
// kopium version: 0.21.0
3+
// kopium version: 0.21.1
44

55
#[allow(unused_imports)]
66
mod prelude {

gateway-api/src/apis/experimental/udproutes.rs renamed to gateway-api/src/experimental/udproutes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// WARNING: generated by kopium - manual changes will be overwritten
22
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f -
3-
// kopium version: 0.21.0
3+
// kopium version: 0.21.1
44

55
#[allow(unused_imports)]
66
mod prelude {

gateway-api/src/lib.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
pub mod apis;
2-
31
pub mod duration;
42
pub use duration::Duration;
3+
pub mod standard;
4+
pub use standard::*;
5+
6+
cfg_if::cfg_if! {
7+
if #[cfg(feature = "experimental")] {
8+
pub mod experimental;
9+
} else {
10+
11+
}
12+
}
513

614
#[cfg(test)]
715
mod tests {
@@ -22,7 +30,7 @@ mod tests {
2230
use tower::ServiceBuilder;
2331
use uuid::Uuid;
2432

25-
use crate::apis::standard::{
33+
use crate::{
2634
constants::{
2735
GatewayConditionReason, GatewayConditionType, ListenerConditionReason,
2836
ListenerConditionType,

gateway-api/src/apis/standard/enum_defaults.rs renamed to gateway-api/src/standard/enum_defaults.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ use super::httproutes::{
77
HTTPRouteRulesFiltersUrlRewritePathType,
88
};
99

10+
use super::grpcroutes::{GRPCRouteRulesBackendRefsFiltersType, GRPCRouteRulesFiltersType};
11+
12+
impl Default for GRPCRouteRulesBackendRefsFiltersType {
13+
fn default() -> Self {
14+
GRPCRouteRulesBackendRefsFiltersType::RequestHeaderModifier
15+
}
16+
}
17+
18+
impl Default for GRPCRouteRulesFiltersType {
19+
fn default() -> Self {
20+
GRPCRouteRulesFiltersType::RequestHeaderModifier
21+
}
22+
}
23+
1024
impl Default for HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType {
1125
fn default() -> Self {
1226
HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType::ReplaceFullPath

gateway-api/src/apis/standard/gatewayclasses.rs renamed to gateway-api/src/standard/gatewayclasses.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// WARNING: generated by kopium - manual changes will be overwritten
22
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f -
3-
// kopium version: 0.21.0
3+
// kopium version: 0.21.1
44

55
#[allow(unused_imports)]
66
mod prelude {

gateway-api/src/apis/standard/gateways.rs renamed to gateway-api/src/standard/gateways.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// WARNING: generated by kopium - manual changes will be overwritten
22
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f -
3-
// kopium version: 0.21.0
3+
// kopium version: 0.21.1
44

55
#[allow(unused_imports)]
66
mod prelude {

gateway-api/src/apis/standard/grpcroutes.rs renamed to gateway-api/src/standard/grpcroutes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// WARNING: generated by kopium - manual changes will be overwritten
22
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f -
3-
// kopium version: 0.21.0
3+
// kopium version: 0.21.1
44

55
#[allow(unused_imports)]
66
mod prelude {
@@ -327,7 +327,7 @@ pub struct GRPCRouteRules {
327327
///
328328
/// For example, take the following matches configuration:
329329
///
330-
/// ```
330+
/// ```text
331331
/// matches:
332332
/// - method:
333333
/// service: foo.bar
@@ -1305,7 +1305,7 @@ pub enum GRPCRouteRulesFiltersType {
13051305
/// For example, the match below will match a gRPC request only if its service
13061306
/// is `foo` AND it contains the `version: v1` header:
13071307
///
1308-
/// ```
1308+
/// ```text
13091309
/// matches:
13101310
/// - method:
13111311
/// type: Exact

gateway-api/src/apis/standard/httproutes.rs renamed to gateway-api/src/standard/httproutes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// WARNING: generated by kopium - manual changes will be overwritten
22
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f -
3-
// kopium version: 0.21.0
3+
// kopium version: 0.21.1
44

55
#[allow(unused_imports)]
66
mod prelude {
@@ -349,7 +349,7 @@ pub struct HTTPRouteRules {
349349
///
350350
/// For example, take the following matches configuration:
351351
///
352-
/// ```
352+
/// ```text
353353
/// matches:
354354
/// - path:
355355
/// value: "/foo"
@@ -1871,7 +1871,7 @@ pub enum HTTPRouteRulesFiltersUrlRewritePathType {
18711871
/// For example, the match below will match a HTTP request only if its path
18721872
/// starts with `/foo` AND it contains the `version: v1` header:
18731873
///
1874-
/// ```
1874+
/// ```text
18751875
/// match:
18761876
///
18771877
/// path:
@@ -1962,7 +1962,7 @@ pub enum HTTPRouteRulesMatchesHeadersType {
19621962
/// For example, the match below will match a HTTP request only if its path
19631963
/// starts with `/foo` AND it contains the `version: v1` header:
19641964
///
1965-
/// ```
1965+
/// ```text
19661966
/// match:
19671967
///
19681968
/// path:

gateway-api/src/apis/standard/referencegrants.rs renamed to gateway-api/src/standard/referencegrants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// WARNING: generated by kopium - manual changes will be overwritten
22
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f -
3-
// kopium version: 0.21.0
3+
// kopium version: 0.21.1
44

55
#[allow(unused_imports)]
66
mod prelude {

update.sh

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ STANDARD_APIS=(
1919
gatewayclasses
2020
gateways
2121
httproutes
22-
grpcroutes
2322
referencegrants
23+
grpcroutes
2424
)
2525

2626
EXPERIMENTAL_APIS=(
@@ -34,24 +34,25 @@ EXPERIMENTAL_APIS=(
3434
udproutes
3535
)
3636

37-
rm -rf gateway-api/src/apis/
37+
rm -rf gateway-api/src/standard/
38+
rm -rf gateway-api/src/experimental/
3839

39-
mkdir -p gateway-api/src/apis/
40-
cat << EOF > gateway-api/src/apis/mod.rs
41-
pub mod experimental;
42-
pub mod standard;
43-
EOF
40+
# mkdir -p gateway-api/src/standard/
41+
# cat << EOF > gateway-api/src/standard/mod.rs
42+
# pub mod experimental;
43+
# pub mod standard;
44+
# EOF
4445

45-
mkdir -p gateway-api/src/apis/standard/
46-
mkdir -p gateway-api/src/apis/experimental/
46+
mkdir -p gateway-api/src/standard/
47+
mkdir -p gateway-api/src/experimental/
4748

48-
echo "// WARNING! generated file do not edit" > gateway-api/src/apis/standard/mod.rs
49+
echo "// WARNING! generated file do not edit" > gateway-api/src/standard/mod.rs
4950

5051
for API in "${STANDARD_APIS[@]}"
5152
do
5253
echo "generating standard api ${API}"
53-
curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/${VERSION}/config/crd/standard/gateway.networking.k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > gateway-api/src/apis/standard/${API}.rs
54-
echo "pub mod ${API};" >> gateway-api/src/apis/standard/mod.rs
54+
curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/${VERSION}/config/crd/standard/gateway.networking.k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > gateway-api/src/standard/${API}.rs
55+
echo "pub mod ${API};" >> gateway-api/src/standard/mod.rs
5556
done
5657

5758
# Standard API enums that need a Default trait impl along with their respective default variant.
@@ -62,15 +63,17 @@ ENUMS=(
6263
HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType=ReplaceFullPath
6364
HTTPRouteRulesBackendRefsFiltersUrlRewritePathType=ReplaceFullPath
6465
HTTPRouteRulesBackendRefsFiltersType=RequestHeaderModifier
66+
GRPCRouteRulesFiltersType=RequestHeaderModifier
67+
GRPCRouteRulesBackendRefsFiltersType=RequestHeaderModifier
6568
)
6669

6770
# Create a comma separated string out of $ENUMS.
6871
ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}")
6972
ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1}
7073

7174
# The task searches for $GATEWAY_API_ENUMS in the enviornment to get the enum names and their default variants.
72-
GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> gateway-api/src/apis/standard/enum_defaults.rs
73-
echo "mod enum_defaults;" >> gateway-api/src/apis/standard/mod.rs
75+
GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> gateway-api/src/standard/enum_defaults.rs
76+
echo "mod enum_defaults;" >> gateway-api/src/standard/mod.rs
7477

7578
GATEWAY_CLASS_CONDITION_CONSTANTS="GatewayClassConditionType=Accepted"
7679
GATEWAY_CLASS_REASON_CONSTANTS="GatewayClassConditionReason=Accepted,InvalidParameters,Pending,Unsupported,Waiting"
@@ -82,16 +85,16 @@ LISTENER_REASON_CONSTANTS="ListenerConditionReason=HostnameConflict,ProtocolConf
8285
GATEWAY_CLASS_CONDITION_CONSTANTS=${GATEWAY_CLASS_CONDITION_CONSTANTS} GATEWAY_CLASS_REASON_CONSTANTS=${GATEWAY_CLASS_REASON_CONSTANTS} \
8386
GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \
8487
LISTENER_CONDITION_CONSTANTS=${LISTENER_CONDITION_CONSTANTS} LISTENER_REASON_CONSTANTS=${LISTENER_REASON_CONSTANTS} \
85-
cargo xtask gen_condition_constants >> gateway-api/src/apis/standard/constants.rs
86-
echo "pub mod constants;" >> gateway-api/src/apis/standard/mod.rs
88+
cargo xtask gen_condition_constants >> gateway-api/src/standard/constants.rs
89+
echo "pub mod constants;" >> gateway-api/src/standard/mod.rs
8790

88-
echo "// WARNING! generated file do not edit" > gateway-api/src/apis/experimental/mod.rs
91+
echo "// WARNING! generated file do not edit" > gateway-api/src/experimental/mod.rs
8992

9093
for API in "${EXPERIMENTAL_APIS[@]}"
9194
do
9295
echo "generating experimental api $API"
93-
curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/${VERSION}/config/crd/experimental/gateway.networking.k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > gateway-api/src/apis/experimental/${API}.rs
94-
echo "pub mod ${API};" >> gateway-api/src/apis/experimental/mod.rs
96+
curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/${VERSION}/config/crd/experimental/gateway.networking.k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > gateway-api/src/experimental/${API}.rs
97+
echo "pub mod ${API};" >> gateway-api/src/experimental/mod.rs
9598
done
9699

97100
# Experimental API enums that need a Default trait impl along with their respective default variant.
@@ -108,8 +111,8 @@ ENUMS=(
108111

109112
ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}")
110113
ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1}
111-
GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> gateway-api/src/apis/experimental/enum_defaults.rs
112-
echo "mod enum_defaults;" >> gateway-api/src/apis/experimental/mod.rs
114+
GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> gateway-api/src/experimental/enum_defaults.rs
115+
echo "mod enum_defaults;" >> gateway-api/src/experimental/mod.rs
113116

114117
# GatewayClass conditions vary between standard and experimental
115118
GATEWAY_CLASS_CONDITION_CONSTANTS="${GATEWAY_CLASS_CONDITION_CONSTANTS},SupportedVersion"
@@ -118,8 +121,8 @@ GATEWAY_CLASS_REASON_CONSTANTS="${GATEWAY_CLASS_REASON_CONSTANTS},SupportedVersi
118121
GATEWAY_CLASS_CONDITION_CONSTANTS=${GATEWAY_CLASS_CONDITION_CONSTANTS} GATEWAY_CLASS_REASON_CONSTANTS=${GATEWAY_CLASS_REASON_CONSTANTS} \
119122
GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \
120123
LISTENER_CONDITION_CONSTANTS=${LISTENER_CONDITION_CONSTANTS} LISTENER_REASON_CONSTANTS=${LISTENER_REASON_CONSTANTS} \
121-
cargo xtask gen_condition_constants >> gateway-api/src/apis/experimental/constants.rs
122-
echo "pub mod constants;" >> gateway-api/src/apis/experimental/mod.rs
124+
cargo xtask gen_condition_constants >> gateway-api/src/experimental/constants.rs
125+
echo "pub mod constants;" >> gateway-api/src/experimental/mod.rs
123126

124127
# Format the code.
125128
cargo fmt

0 commit comments

Comments
 (0)