feat: add extraPortMappings support to ClusterSpec - #16
Conversation
praxis-bot
left a comment
There was a problem hiding this comment.
PR Review
Summary: Clean feature addition -- CreateClusterConfig struct is a good refactor, port generation is correct (first CP node only), validation catches zero ports and duplicates, test coverage is solid. One validation gap where cluster port bindAddress isn't checked.
| Severity | Count |
|---|---|
| Critical | 0 |
| Large | 0 |
| Medium | 1 |
| ))); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
[Medium] check_cluster_ports validates non-zero ports and unique host ports but does not validate bind_address as a valid IP when present. Service ports already do this via check_port_bind_address (line 275). Without it, a cluster port mapping with bindAddress: "not-an-ip" passes validation and produces a malformed KIND config that fails opaquely at kind create cluster time.
Add a bind_address check inside the port loop:
if let Some(addr) = &pm.bind_address {
if addr.parse::<std::net::IpAddr>().is_err() {
return Err(ForgeError::Validation(format!(
"cluster {:?}: port mapping bind address {:?} is not a valid IP",
cluster.name, addr,
)));
}
}Expose KIND extraPortMappings in the forge config schema via a new ports field on ClusterSpec. Enables mapping host ports to container NodePorts for accessing services (Grafana, Prometheus, MLflow) from the host machine. Includes config validation, KIND config generation, and integration test with a port-mappings fixture. Signed-off-by: Ladislav Smola <lsmola@redhat.com>
f92470b to
326515b
Compare
Closes #17
Summary
ports: Vec<PortMapping>toClusterSpecfor KINDextraPortMappingsTest plan
tests/fixtures/port-mappings.yamlextraPortMappingson first control-plane nodecargo test+cargo clippyclean (451 tests)