Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use standard Condition definitions and add a Default derive #30

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
xtask = "run -q --manifest-path ./xtask/Cargo.toml --"
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/target
/Cargo.lock
target
Cargo.lock
30 changes: 2 additions & 28 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,2 @@
[package]
name = "gateway-api"
version = "0.8.1"
description = "Kubernetes Gateway API bindings in Rust"
authors = ["Shane Utt <shaneutt@linux.com>"]
license = "MIT"
keywords = ["kubernetes", "gateway-api"]
categories = ["api-bindings"]
homepage = "https://gateway-api.sigs.k8s.io/"
repository = "https://github.com/kube-rs/gateway-api-rs"
edition = "2021"

[dependencies]
kube = { version = "^0.88.0", default-features = false, features = ["derive"] }
k8s-openapi = { version = "0.21.0", features = ["v1_29"] }
schemars = "0.8.16"
serde = { version = "1.0.195", features = ["derive"] }
serde_json = "1.0.111"
serde_yaml = "0.9.30"

[dev-dependencies]
anyhow = "1.0.79"
hyper = "0.14.28"
kube = { version = "^0.88.0" }
k8s-openapi = { version = "0.21.0" , features = ["v1_29"] }
tokio = { version = "1.35.1", features = ["macros"] }
tower = "0.4.13"
uuid = { version = "1.7.0", features = ["v4", "fast-rng"] }
[workspace]
members = ["gateway-api", "xtask"]
28 changes: 28 additions & 0 deletions gateway-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "gateway-api"
version = "0.8.1"
description = "Kubernetes Gateway API bindings in Rust"
authors = ["Shane Utt <shaneutt@linux.com>"]
license = "MIT"
keywords = ["kubernetes", "gateway-api"]
categories = ["api-bindings"]
homepage = "https://gateway-api.sigs.k8s.io/"
repository = "https://github.com/kube-rs/gateway-api-rs"
edition = "2021"

[dependencies]
kube = { version = "^0.88.0", default-features = false, features = ["derive"] }
k8s-openapi = { version = "0.21.0", features = ["v1_29", "schemars"] }
schemars = "0.8.16"
serde = { version = "1.0.195", features = ["derive"] }
serde_json = "1.0.111"
serde_yaml = "0.9.30"

[dev-dependencies]
anyhow = "1.0.79"
hyper = "0.14.28"
kube = { version = "^0.88.0" }
k8s-openapi = { version = "0.21.0" , features = ["v1_29"] }
tokio = { version = "1.35.1", features = ["macros"] }
tower = "0.4.13"
uuid = { version = "1.7.0", features = ["v4", "fast-rng"] }
58 changes: 58 additions & 0 deletions gateway-api/src/apis/experimental/enum_defaults.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// WARNING: generated file - manual changes will be overriden

use super::httproutes::{
HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType, HTTPRouteRulesBackendRefsFiltersType,
HTTPRouteRulesBackendRefsFiltersUrlRewritePathType,
HTTPRouteRulesFiltersRequestRedirectPathType, HTTPRouteRulesFiltersType,
HTTPRouteRulesFiltersUrlRewritePathType,
};

use super::grpcroutes::{GRPCRouteRulesBackendRefsFiltersType, GRPCRouteRulesFiltersType};

impl Default for GRPCRouteRulesBackendRefsFiltersType {
fn default() -> Self {
GRPCRouteRulesBackendRefsFiltersType::RequestHeaderModifier
}
}

impl Default for GRPCRouteRulesFiltersType {
fn default() -> Self {
GRPCRouteRulesFiltersType::RequestHeaderModifier
}
}

impl Default for HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType {
fn default() -> Self {
HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType::ReplaceFullPath
}
}

impl Default for HTTPRouteRulesBackendRefsFiltersType {
fn default() -> Self {
HTTPRouteRulesBackendRefsFiltersType::RequestHeaderModifier
}
}

impl Default for HTTPRouteRulesBackendRefsFiltersUrlRewritePathType {
fn default() -> Self {
HTTPRouteRulesBackendRefsFiltersUrlRewritePathType::ReplaceFullPath
}
}

impl Default for HTTPRouteRulesFiltersRequestRedirectPathType {
fn default() -> Self {
HTTPRouteRulesFiltersRequestRedirectPathType::ReplaceFullPath
}
}

impl Default for HTTPRouteRulesFiltersType {
fn default() -> Self {
HTTPRouteRulesFiltersType::RequestHeaderModifier
}
}

impl Default for HTTPRouteRulesFiltersUrlRewritePathType {
fn default() -> Self {
HTTPRouteRulesFiltersUrlRewritePathType::ReplaceFullPath
}
}
73 changes: 73 additions & 0 deletions gateway-api/src/apis/experimental/gatewayclasses.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// WARNING: generated by kopium - manual changes will be overwritten
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --docs -f -
// kopium version: 0.17.2

use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition;
use kube::CustomResource;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

/// Spec defines the desired state of GatewayClass.
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default)]
#[kube(
group = "gateway.networking.k8s.io",
version = "v1",
kind = "GatewayClass",
plural = "gatewayclasses"
)]
#[kube(status = "GatewayClassStatus")]
pub struct GatewayClassSpec {
/// 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.
/// Example: "example.net/gateway-controller".
/// This field is not mutable and cannot be empty.
/// Support: Core
#[serde(rename = "controllerName")]
pub controller_name: String,
/// Description helps describe a GatewayClass with more details.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
/// 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.
/// 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.
/// If the referent cannot be found, the GatewayClass's "InvalidParameters" status condition will be true.
/// Support: Implementation-specific
#[serde(
default,
skip_serializing_if = "Option::is_none",
rename = "parametersRef"
)]
pub parameters_ref: Option<GatewayClassParametersRef>,
}

/// 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.
/// 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.
/// If the referent cannot be found, the GatewayClass's "InvalidParameters" status condition will be true.
/// Support: Implementation-specific
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default)]
pub struct GatewayClassParametersRef {
/// Group is the group of the referent.
pub group: String,
/// Kind is kind of the referent.
pub kind: String,
/// Name is the name of the referent.
pub name: String,
/// 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.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub namespace: Option<String>,
}

/// Status defines the current state of GatewayClass.
/// Implementations MUST populate status on all GatewayClass resources which specify their controller name.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default)]
pub struct GatewayClassStatus {
/// Conditions is the current status from the controller for this GatewayClass.
/// Controllers should prefer to publish conditions using values of GatewayClassConditionType for the type of each Condition.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub conditions: Option<Vec<Condition>>,
/// SupportedFeatures is the set of features the GatewayClass support. It MUST be sorted in ascending alphabetical order.
#[serde(
default,
skip_serializing_if = "Option::is_none",
rename = "supportedFeatures"
)]
pub supported_features: Option<Vec<String>>,
}
Loading
Loading