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
|
All contributors have signed the DCO ✍️ ✅ |
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. |
|
recheck |
|
The function was removed, and I replaced the call in the create sandbox function with the existing function. The tests were also removed for the new function and two tests were added that test the validate_kubernetes_dns1123_label were added to check for these edge cases. |
|
/ok-to-test e96b64d |
|
Label |
|
Label |
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