Skip to content

Commit

Permalink
feat: add constants for GatewayClass conditions
Browse files Browse the repository at this point in the history
Signed-off-by: Aidan Harbison <[email protected]>
  • Loading branch information
aharbis committed Jan 7, 2025
1 parent 1fab07f commit 1f942e9
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
29 changes: 29 additions & 0 deletions gateway-api/src/apis/experimental/constants.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
// WARNING: generated file - manual changes will be overriden

#[derive(Debug, PartialEq, Eq)]
pub enum GatewayClassConditionType {
Accepted,
SupportedVersion,
}

impl std::fmt::Display for GatewayClassConditionType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

#[derive(Debug, PartialEq, Eq)]
pub enum GatewayClassConditionReason {
Accepted,
InvalidParameters,
Pending,
Unsupported,
Waiting,
SupportedVersion,
UnsupportedVersion,
}

impl std::fmt::Display for GatewayClassConditionReason {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

#[derive(Debug, PartialEq, Eq)]
pub enum GatewayConditionType {
Programmed,
Expand Down
26 changes: 26 additions & 0 deletions gateway-api/src/apis/standard/constants.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
// WARNING: generated file - manual changes will be overriden

#[derive(Debug, PartialEq, Eq)]
pub enum GatewayClassConditionType {
Accepted,
}

impl std::fmt::Display for GatewayClassConditionType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

#[derive(Debug, PartialEq, Eq)]
pub enum GatewayClassConditionReason {
Accepted,
InvalidParameters,
Pending,
Unsupported,
Waiting,
}

impl std::fmt::Display for GatewayClassConditionReason {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

#[derive(Debug, PartialEq, Eq)]
pub enum GatewayConditionType {
Programmed,
Expand Down
12 changes: 10 additions & 2 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1}
GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> gateway-api/src/apis/standard/enum_defaults.rs
echo "mod enum_defaults;" >> gateway-api/src/apis/standard/mod.rs

GATEWAY_CLASS_CONDITION_CONSTANTS="GatewayClassConditionType=Accepted"
GATEWAY_CLASS_REASON_CONSTANTS="GatewayClassConditionReason=Accepted,InvalidParameters,Pending,Unsupported,Waiting"
GATEWAY_CONDITION_CONSTANTS="GatewayConditionType=Programmed,Accepted,Ready"
GATEWAY_REASON_CONSTANTS="GatewayConditionReason=Programmed,Invalid,NoResources,AddressNotAssigned,AddressNotUsable,Accepted,ListenersNotValid,Pending,UnsupportedAddress,InvalidParameters,Ready,ListenersNotReady"
LISTENER_CONDITION_CONSTANTS="ListenerConditionType=Conflicted,Accepted,ResolvedRefs,Programmed,Ready"
LISTENER_REASON_CONSTANTS="ListenerConditionReason=HostnameConflict,ProtocolConflict,NoConflicts,Accepted,PortUnavailable,UnsupportedProtocol,ResolvedRefs,InvalidCertificateRef,InvalidRouteKinds,RefNotPermitted,Programmed,Invalid,Pending,Ready"

GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \
GATEWAY_CLASS_CONDITION_CONSTANTS=${GATEWAY_CLASS_CONDITION_CONSTANTS} GATEWAY_CLASS_REASON_CONSTANTS=${GATEWAY_CLASS_REASON_CONSTANTS} \
GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \
LISTENER_CONDITION_CONSTANTS=${LISTENER_CONDITION_CONSTANTS} LISTENER_REASON_CONSTANTS=${LISTENER_REASON_CONSTANTS} \
cargo xtask gen_condition_constants >> gateway-api/src/apis/standard/constants.rs
echo "pub mod constants;" >> gateway-api/src/apis/standard/mod.rs
Expand Down Expand Up @@ -107,7 +110,12 @@ ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1}
GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> gateway-api/src/apis/experimental/enum_defaults.rs
echo "mod enum_defaults;" >> gateway-api/src/apis/experimental/mod.rs

GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \
# GatewayClass conditions vary between standard and experimental
GATEWAY_CLASS_CONDITION_CONSTANTS="GatewayClassConditionType=Accepted,SupportedVersion"
GATEWAY_CLASS_REASON_CONSTANTS="GatewayClassConditionReason=Accepted,InvalidParameters,Pending,Unsupported,Waiting,SupportedVersion,UnsupportedVersion"

GATEWAY_CLASS_CONDITION_CONSTANTS=${GATEWAY_CLASS_CONDITION_CONSTANTS} GATEWAY_CLASS_REASON_CONSTANTS=${GATEWAY_CLASS_REASON_CONSTANTS} \
GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \
LISTENER_CONDITION_CONSTANTS=${LISTENER_CONDITION_CONSTANTS} LISTENER_REASON_CONSTANTS=${LISTENER_REASON_CONSTANTS} \
cargo xtask gen_condition_constants >> gateway-api/src/apis/experimental/constants.rs
echo "pub mod constants;" >> gateway-api/src/apis/experimental/mod.rs
Expand Down
4 changes: 4 additions & 0 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ gen_constants generates constants used for Conditions
type DynError = Box<dyn std::error::Error>;

fn gen_condition_constants() -> Result<(), DynError> {
let gateway_class_condition_types = env::var("GATEWAY_CLASS_CONDITION_CONSTANTS")?;
let gateway_class_reason_types = env::var("GATEWAY_CLASS_REASON_CONSTANTS")?;
let gateway_condition_types = env::var("GATEWAY_CONDITION_CONSTANTS")?;
let gateway_reason_types = env::var("GATEWAY_REASON_CONSTANTS")?;
let listener_condition_types = env::var("LISTENER_CONDITION_CONSTANTS")?;
let listener_reason_types = env::var("LISTENER_REASON_CONSTANTS")?;

let mut scope = Scope::new();
gen_const_enums(&mut scope, gateway_class_condition_types);
gen_const_enums(&mut scope, gateway_class_reason_types);
gen_const_enums(&mut scope, gateway_condition_types);
gen_const_enums(&mut scope, gateway_reason_types);
gen_const_enums(&mut scope, listener_condition_types);
Expand Down

0 comments on commit 1f942e9

Please sign in to comment.