Skip to content

Commit 6a4abd6

Browse files
authored
Route condition reason (#194)
Signed-off-by: Raphael Tomé Santana <[email protected]>
1 parent 7b79c91 commit 6a4abd6

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

gateway-api/src/apis/experimental/constants.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,32 @@ impl std::fmt::Display for ListenerConditionReason {
9191
write!(f, "{:?}", self)
9292
}
9393
}
94+
95+
#[derive(Debug, PartialEq, Eq)]
96+
pub enum RouteConditionType {
97+
Accepted,
98+
ResolvedRefs,
99+
}
100+
impl std::fmt::Display for RouteConditionType {
101+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
102+
write!(f, "{:?}", self)
103+
}
104+
}
105+
106+
#[derive(Debug, PartialEq, Eq)]
107+
pub enum RouteConditionReason {
108+
Accepted,
109+
NotAllowedByListeners,
110+
NoMatchingListenerHostname,
111+
UnsupportedValue,
112+
Pending,
113+
ResolvedRefs,
114+
RefNotPermitted,
115+
InvalidKind,
116+
BackendNotFound,
117+
}
118+
impl std::fmt::Display for RouteConditionReason {
119+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
120+
write!(f, "{:?}", self)
121+
}
122+
}

gateway-api/src/apis/standard/constants.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,36 @@ impl std::fmt::Display for ListenerConditionReason {
8888
write!(f, "{:?}", self)
8989
}
9090
}
91+
92+
#[derive(Debug, PartialEq, Eq)]
93+
pub enum RouteConditionType {
94+
Accepted,
95+
ResolvedRefs,
96+
PartiallyInvalid,
97+
}
98+
impl std::fmt::Display for RouteConditionType {
99+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
100+
write!(f, "{:?}", self)
101+
}
102+
}
103+
104+
#[derive(Debug, PartialEq, Eq)]
105+
pub enum RouteConditionReason {
106+
Accepted,
107+
NotAllowedByListeners,
108+
NoMatchingListenerHostname,
109+
NoMatchingParent,
110+
UnsupportedValue,
111+
Pending,
112+
IncompatibleFilters,
113+
ResolvedRefs,
114+
RefNotPermitted,
115+
InvalidKind,
116+
BackendNotFound,
117+
UnsupportedProtocol,
118+
}
119+
impl std::fmt::Display for RouteConditionReason {
120+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
121+
write!(f, "{:?}", self)
122+
}
123+
}

update.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,13 @@ GATEWAY_CONDITION_CONSTANTS="GatewayConditionType=Programmed,Accepted,Ready"
8484
GATEWAY_REASON_CONSTANTS="GatewayConditionReason=Programmed,Invalid,NoResources,AddressNotAssigned,AddressNotUsable,Accepted,ListenersNotValid,Pending,UnsupportedAddress,InvalidParameters,Ready,ListenersNotReady"
8585
LISTENER_CONDITION_CONSTANTS="ListenerConditionType=Conflicted,Accepted,ResolvedRefs,Programmed,Ready"
8686
LISTENER_REASON_CONSTANTS="ListenerConditionReason=HostnameConflict,ProtocolConflict,NoConflicts,Accepted,PortUnavailable,UnsupportedProtocol,ResolvedRefs,InvalidCertificateRef,InvalidRouteKinds,RefNotPermitted,Programmed,Invalid,Pending,Ready"
87+
ROUTE_CONDITION_CONSTANTS="RouteConditionType=Accepted,ResolvedRefs,PartiallyInvalid"
88+
ROUTE_REASON_CONSTANTS="RouteConditionReason=Accepted,NotAllowedByListeners,NoMatchingListenerHostname,NoMatchingParent,UnsupportedValue,Pending,IncompatibleFilters,ResolvedRefs,RefNotPermitted,InvalidKind,BackendNotFound,UnsupportedProtocol"
8789

8890
GATEWAY_CLASS_CONDITION_CONSTANTS=${GATEWAY_CLASS_CONDITION_CONSTANTS} GATEWAY_CLASS_REASON_CONSTANTS=${GATEWAY_CLASS_REASON_CONSTANTS} \
8991
GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \
9092
LISTENER_CONDITION_CONSTANTS=${LISTENER_CONDITION_CONSTANTS} LISTENER_REASON_CONSTANTS=${LISTENER_REASON_CONSTANTS} \
93+
ROUTE_CONDITION_CONSTANTS=${ROUTE_CONDITION_CONSTANTS} ROUTE_REASON_CONSTANTS=${ROUTE_REASON_CONSTANTS} \
9194
cargo xtask gen_condition_constants >> $APIS_DIR/standard/constants.rs
9295
echo "pub mod constants;" >> $APIS_DIR/standard/mod.rs
9396

@@ -122,10 +125,13 @@ echo "mod enum_defaults;" >> $APIS_DIR/experimental/mod.rs
122125
# GatewayClass conditions vary between standard and experimental
123126
GATEWAY_CLASS_CONDITION_CONSTANTS="${GATEWAY_CLASS_CONDITION_CONSTANTS},SupportedVersion"
124127
GATEWAY_CLASS_REASON_CONSTANTS="${GATEWAY_CLASS_REASON_CONSTANTS},SupportedVersion,UnsupportedVersion"
128+
ROUTE_CONDITION_CONSTANTS="RouteConditionType=Accepted,ResolvedRefs"
129+
ROUTE_REASON_CONSTANTS="RouteConditionReason=Accepted,NotAllowedByListeners,NoMatchingListenerHostname,UnsupportedValue,Pending,ResolvedRefs,RefNotPermitted,InvalidKind,BackendNotFound"
125130

126131
GATEWAY_CLASS_CONDITION_CONSTANTS=${GATEWAY_CLASS_CONDITION_CONSTANTS} GATEWAY_CLASS_REASON_CONSTANTS=${GATEWAY_CLASS_REASON_CONSTANTS} \
127132
GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \
128133
LISTENER_CONDITION_CONSTANTS=${LISTENER_CONDITION_CONSTANTS} LISTENER_REASON_CONSTANTS=${LISTENER_REASON_CONSTANTS} \
134+
ROUTE_CONDITION_CONSTANTS=${ROUTE_CONDITION_CONSTANTS} ROUTE_REASON_CONSTANTS=${ROUTE_REASON_CONSTANTS} \
129135
cargo xtask gen_condition_constants >> $APIS_DIR/experimental/constants.rs
130136
echo "pub mod constants;" >> $APIS_DIR/experimental/mod.rs
131137

xtask/src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ fn gen_condition_constants() -> Result<(), DynError> {
3131
let gateway_reason_types = env::var("GATEWAY_REASON_CONSTANTS")?;
3232
let listener_condition_types = env::var("LISTENER_CONDITION_CONSTANTS")?;
3333
let listener_reason_types = env::var("LISTENER_REASON_CONSTANTS")?;
34+
let route_condition_types = env::var("ROUTE_CONDITION_CONSTANTS")?;
35+
let route_reason_types = env::var("ROUTE_REASON_CONSTANTS")?;
3436

3537
let mut scope = Scope::new();
3638
gen_const_enums(&mut scope, gateway_class_condition_types);
@@ -39,6 +41,8 @@ fn gen_condition_constants() -> Result<(), DynError> {
3941
gen_const_enums(&mut scope, gateway_reason_types);
4042
gen_const_enums(&mut scope, listener_condition_types);
4143
gen_const_enums(&mut scope, listener_reason_types);
44+
gen_const_enums(&mut scope, route_condition_types);
45+
gen_const_enums(&mut scope, route_reason_types);
4246
println!("{}", gen_generated_file_warning());
4347
println!("{}", scope.to_string());
4448
Ok(())

0 commit comments

Comments
 (0)