fix(kubernetes): validate sandbox names against RFC 1123 requirements#2295
fix(kubernetes): validate sandbox names against RFC 1123 requirements#22952000krysztof wants to merge 1 commit into
Conversation
|
Thank you for your submission! We ask that you sign our Developer Certificate of Origin before we can accept your contribution. You can sign the DCO by adding a comment below using this text: I have read the DCO document and I hereby sign the DCO. You can retrigger this bot by commenting recheck in this Pull Request. Posted by the DCO Assistant Lite bot. |
elezar
left a comment
There was a problem hiding this comment.
Thanks for adding validation before the Kubernetes API call. I think this should reuse the DNS-1123 validation we already have instead of introducing a second sandbox-name validator.
crates/openshell-driver-kubernetes/src/driver.rs already defines validate_kubernetes_dns1123_label() and validate_kubernetes_dns1123_subdomain() near the existing driver volume validation code. The label helper enforces the same shape needed here: non-empty, max 63 chars, lowercase alphanumeric or -, and start/end alphanumeric. It is already covered by the driver-config DNS-1123 tests.
Please replace the new validate_k8s_name() implementation with a call like:
validate_kubernetes_dns1123_label(&sandbox.name, "sandbox.name")
.map_err(KubernetesDriverError::InvalidArgument)?;That keeps the Kubernetes driver on one validation primitive and avoids two slightly different RFC 1123 implementations drifting over time. If we want better sandbox-specific wording, we should add that around the existing helper or promote a shared helper into openshell_core, rather than duplicating the parsing logic.
Signed-off-by: Krzysztof Malczuk <kmalczuk@redhat.com>
e1841c5 to
e96b64d
Compare
|
I have read the DCO document and I hereby sign the DCO. |
Summary
This PR adds a call to the validate_kubernetes_dns1123_label inside of create_sandbox function.
Related Issue
Fixes #2115
Changes
Testing
mise run pre-commitpassesChecklist