Skip to content

Commit 298804f

Browse files
authored
Use standard Condition definitions and add a Default derive (#30)
Signed-off-by: Sanskar Jaiswal <[email protected]>
1 parent 6445a4c commit 298804f

37 files changed

+4891
-11268
lines changed

.cargo/config.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[alias]
2+
xtask = "run -q --manifest-path ./xtask/Cargo.toml --"

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
/target
2-
/Cargo.lock
1+
target
2+
Cargo.lock

Cargo.toml

+2-28
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,2 @@
1-
[package]
2-
name = "gateway-api"
3-
version = "0.8.1"
4-
description = "Kubernetes Gateway API bindings in Rust"
5-
authors = ["Shane Utt <[email protected]>"]
6-
license = "MIT"
7-
keywords = ["kubernetes", "gateway-api"]
8-
categories = ["api-bindings"]
9-
homepage = "https://gateway-api.sigs.k8s.io/"
10-
repository = "https://github.com/kube-rs/gateway-api-rs"
11-
edition = "2021"
12-
13-
[dependencies]
14-
kube = { version = "^0.88.0", default-features = false, features = ["derive"] }
15-
k8s-openapi = { version = "0.21.0", features = ["v1_29"] }
16-
schemars = "0.8.16"
17-
serde = { version = "1.0.195", features = ["derive"] }
18-
serde_json = "1.0.111"
19-
serde_yaml = "0.9.30"
20-
21-
[dev-dependencies]
22-
anyhow = "1.0.79"
23-
hyper = "0.14.28"
24-
kube = { version = "^0.88.0" }
25-
k8s-openapi = { version = "0.21.0" , features = ["v1_29"] }
26-
tokio = { version = "1.35.1", features = ["macros"] }
27-
tower = "0.4.13"
28-
uuid = { version = "1.7.0", features = ["v4", "fast-rng"] }
1+
[workspace]
2+
members = ["gateway-api", "xtask"]

gateway-api/Cargo.toml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[package]
2+
name = "gateway-api"
3+
version = "0.8.1"
4+
description = "Kubernetes Gateway API bindings in Rust"
5+
authors = ["Shane Utt <[email protected]>"]
6+
license = "MIT"
7+
keywords = ["kubernetes", "gateway-api"]
8+
categories = ["api-bindings"]
9+
homepage = "https://gateway-api.sigs.k8s.io/"
10+
repository = "https://github.com/kube-rs/gateway-api-rs"
11+
edition = "2021"
12+
13+
[dependencies]
14+
kube = { version = "^0.88.0", default-features = false, features = ["derive"] }
15+
k8s-openapi = { version = "0.21.0", features = ["v1_29", "schemars"] }
16+
schemars = "0.8.16"
17+
serde = { version = "1.0.195", features = ["derive"] }
18+
serde_json = "1.0.111"
19+
serde_yaml = "0.9.30"
20+
21+
[dev-dependencies]
22+
anyhow = "1.0.79"
23+
hyper = "0.14.28"
24+
kube = { version = "^0.88.0" }
25+
k8s-openapi = { version = "0.21.0" , features = ["v1_29"] }
26+
tokio = { version = "1.35.1", features = ["macros"] }
27+
tower = "0.4.13"
28+
uuid = { version = "1.7.0", features = ["v4", "fast-rng"] }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// WARNING: generated file - manual changes will be overriden
2+
3+
use super::httproutes::{
4+
HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType, HTTPRouteRulesBackendRefsFiltersType,
5+
HTTPRouteRulesBackendRefsFiltersUrlRewritePathType,
6+
HTTPRouteRulesFiltersRequestRedirectPathType, HTTPRouteRulesFiltersType,
7+
HTTPRouteRulesFiltersUrlRewritePathType,
8+
};
9+
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+
24+
impl Default for HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType {
25+
fn default() -> Self {
26+
HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType::ReplaceFullPath
27+
}
28+
}
29+
30+
impl Default for HTTPRouteRulesBackendRefsFiltersType {
31+
fn default() -> Self {
32+
HTTPRouteRulesBackendRefsFiltersType::RequestHeaderModifier
33+
}
34+
}
35+
36+
impl Default for HTTPRouteRulesBackendRefsFiltersUrlRewritePathType {
37+
fn default() -> Self {
38+
HTTPRouteRulesBackendRefsFiltersUrlRewritePathType::ReplaceFullPath
39+
}
40+
}
41+
42+
impl Default for HTTPRouteRulesFiltersRequestRedirectPathType {
43+
fn default() -> Self {
44+
HTTPRouteRulesFiltersRequestRedirectPathType::ReplaceFullPath
45+
}
46+
}
47+
48+
impl Default for HTTPRouteRulesFiltersType {
49+
fn default() -> Self {
50+
HTTPRouteRulesFiltersType::RequestHeaderModifier
51+
}
52+
}
53+
54+
impl Default for HTTPRouteRulesFiltersUrlRewritePathType {
55+
fn default() -> Self {
56+
HTTPRouteRulesFiltersUrlRewritePathType::ReplaceFullPath
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// WARNING: generated by kopium - manual changes will be overwritten
2+
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --docs -f -
3+
// kopium version: 0.17.2
4+
5+
use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition;
6+
use kube::CustomResource;
7+
use schemars::JsonSchema;
8+
use serde::{Deserialize, Serialize};
9+
10+
/// Spec defines the desired state of GatewayClass.
11+
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default)]
12+
#[kube(
13+
group = "gateway.networking.k8s.io",
14+
version = "v1",
15+
kind = "GatewayClass",
16+
plural = "gatewayclasses"
17+
)]
18+
#[kube(status = "GatewayClassStatus")]
19+
pub struct GatewayClassSpec {
20+
/// ControllerName is the name of the controller that is managing Gateways of this class. The value of this field MUST be a domain prefixed path.
21+
/// Example: "example.net/gateway-controller".
22+
/// This field is not mutable and cannot be empty.
23+
/// Support: Core
24+
#[serde(rename = "controllerName")]
25+
pub controller_name: String,
26+
/// Description helps describe a GatewayClass with more details.
27+
#[serde(default, skip_serializing_if = "Option::is_none")]
28+
pub description: Option<String>,
29+
/// ParametersRef is a reference to a resource that contains the configuration parameters corresponding to the GatewayClass. This is optional if the controller does not require any additional configuration.
30+
/// ParametersRef can reference a standard Kubernetes resource, i.e. ConfigMap, or an implementation-specific custom resource. The resource can be cluster-scoped or namespace-scoped.
31+
/// If the referent cannot be found, the GatewayClass's "InvalidParameters" status condition will be true.
32+
/// Support: Implementation-specific
33+
#[serde(
34+
default,
35+
skip_serializing_if = "Option::is_none",
36+
rename = "parametersRef"
37+
)]
38+
pub parameters_ref: Option<GatewayClassParametersRef>,
39+
}
40+
41+
/// ParametersRef is a reference to a resource that contains the configuration parameters corresponding to the GatewayClass. This is optional if the controller does not require any additional configuration.
42+
/// ParametersRef can reference a standard Kubernetes resource, i.e. ConfigMap, or an implementation-specific custom resource. The resource can be cluster-scoped or namespace-scoped.
43+
/// If the referent cannot be found, the GatewayClass's "InvalidParameters" status condition will be true.
44+
/// Support: Implementation-specific
45+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default)]
46+
pub struct GatewayClassParametersRef {
47+
/// Group is the group of the referent.
48+
pub group: String,
49+
/// Kind is kind of the referent.
50+
pub kind: String,
51+
/// Name is the name of the referent.
52+
pub name: String,
53+
/// Namespace is the namespace of the referent. This field is required when referring to a Namespace-scoped resource and MUST be unset when referring to a Cluster-scoped resource.
54+
#[serde(default, skip_serializing_if = "Option::is_none")]
55+
pub namespace: Option<String>,
56+
}
57+
58+
/// Status defines the current state of GatewayClass.
59+
/// Implementations MUST populate status on all GatewayClass resources which specify their controller name.
60+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default)]
61+
pub struct GatewayClassStatus {
62+
/// Conditions is the current status from the controller for this GatewayClass.
63+
/// Controllers should prefer to publish conditions using values of GatewayClassConditionType for the type of each Condition.
64+
#[serde(default, skip_serializing_if = "Option::is_none")]
65+
pub conditions: Option<Vec<Condition>>,
66+
/// SupportedFeatures is the set of features the GatewayClass support. It MUST be sorted in ascending alphabetical order.
67+
#[serde(
68+
default,
69+
skip_serializing_if = "Option::is_none",
70+
rename = "supportedFeatures"
71+
)]
72+
pub supported_features: Option<Vec<String>>,
73+
}

0 commit comments

Comments
 (0)