Skip to content

Commit 233d927

Browse files
committed
fix(kubernetes): accept chart's httproute spelling for service ingress kind
The Helm chart documents and passes serviceIngress.kind=httproute through to the gateway TOML verbatim, but ServiceIngressKind's snake_case serde rename only accepted http_route, so the documented value failed gateway config validation and crashlooped the pod. route and ingress happened to match both vocabularies, so only the httproute path was broken. Accept httproute as a serde alias on the HttpRoute variant. The canonical wire value stays http_route; tests cover both spellings and rejection of unknown values. Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
1 parent 72dfd92 commit 233d927

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

  • crates/openshell-driver-kubernetes/src

‎crates/openshell-driver-kubernetes/src/config.rs‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,11 @@ pub enum ServiceIngressKind {
453453
#[default]
454454
Route,
455455
/// Gateway API `HTTPRoute` attached to the configured parent `Gateway`.
456+
/// The canonical wire value is `http_route` (snake_case, matching every
457+
/// other config key); the Helm chart surfaces `httproute` (matching the
458+
/// Kubernetes kind) and passes it through verbatim, so that spelling is
459+
/// accepted as an alias.
460+
#[serde(alias = "httproute")]
456461
HttpRoute,
457462
/// `networking.k8s.io/v1` `Ingress`. Requires an ingress controller that
458463
/// supports SSL passthrough (the annotation is set for nginx).
@@ -1304,6 +1309,29 @@ mod tests {
13041309
}
13051310
}
13061311

1312+
#[test]
1313+
fn service_ingress_kind_accepts_chart_and_snake_case_spellings() {
1314+
for value in ["http_route", "httproute"] {
1315+
let input = format!(
1316+
"[service_ingress]\nenabled = true\nkind = \"{value}\"\n\
1317+
target_service_name = \"gw\"\n\
1318+
target_service_namespace = \"ns\"\n\
1319+
target_service_port = 8080\n\
1320+
http_route_parent_gateway = \"gw\"\n\
1321+
poll_interval_secs = 5\n"
1322+
);
1323+
let config: KubernetesComputeConfig = toml::from_str(&input)
1324+
.unwrap_or_else(|error| panic!("{value} should parse: {error}"));
1325+
assert_eq!(config.service_ingress.kind, ServiceIngressKind::HttpRoute);
1326+
}
1327+
}
1328+
1329+
#[test]
1330+
fn service_ingress_kind_rejects_unknown_values() {
1331+
let input = "[service_ingress]\nenabled = true\nkind = \"routes\"";
1332+
assert!(toml::from_str::<KubernetesComputeConfig>(input).is_err());
1333+
}
1334+
13071335
#[test]
13081336
fn published_kubernetes_example_is_valid_toml() {
13091337
let docs = include_str!("../../../docs/how-it-works/gateways/configuration.mdx");

0 commit comments

Comments
 (0)