[patch] auto-sanitize registry prefix to comply with RFC 1123#2471
Merged
Conversation
durera
approved these changes
Jul 14, 2026
Contributor
|
FYI, you might want to look at the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Auto-sanitize the registry prefix to comply with RFC 1123 naming rules, preventing validation errors and OpenShift API rejections caused by invalid characters in the prefix.
Problem
When users run
mas configure-airgap,mas mirror-images, ormas mirror-redhatwith a registry prefix containing characters such as/,\, uppercase letters, or spaces, one of two failures occurs:1. CLI validation failure —
validate_registry_prefixrejects the prefix withexit 1:2. OpenShift API failure — if validation is bypassed, the
ocp_idmsAnsible role builds an invalid IDMS resource name which OpenShift rejects:Solution
Introduce a new
sanitize_registry_prefix()function inimage/cli/mascli/functions/internal/utilsthat automatically normalises the prefix before validation:test/testtest-test/replaced with-test_testtest-test_replaced with-MyPrefixmyprefixtest--testtest-test-test-test-strippedMY/folder/pathmy-folder-pathIf the value changes during sanitization, a yellow informational note is printed:
Valid prefixes pass through unchanged with no output.
Also Fixed
Pre-existing bash syntax bug in
configure_airgap— spaces around=in variable assignments causedcommand not founderrors in interactive mode:Files Changed
image/cli/mascli/functions/internal/utilssanitize_registry_prefix()image/cli/mascli/functions/configure_airgapimage/cli/mascli/functions/mirror_imagesimage/cli/mascli/functions/mirror_images_commonimage/cli/mascli/functions/mirror_redhatTesting
Manually tested end-to-end on an OCP cluster with a local Docker registry:
mas mirror-images --prefix "test/test"→ sanitized totest-test, mirroring proceeded with correct target pathhost:5000/test-test/cpopen/...mas configure-airgap --prefix "test/jeel123"→ sanitized totest-jeel123, IDMS resource created asmas-ibm-catalog-test-jeel123test-test,abc.123) → pass through unchanged, no warning printed