fix(mirror-plugins): prevent OCI URL path prefix stacking when target registry includes a path#2982
Conversation
… registry includes a path Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
Code Review by Qodo
1.
|
|
cc/ @rm3l |
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 410b734 |
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
|
| # Use jq to update all registryReference values | ||
| # Replace the registry domain (first component before /) with target registry | ||
| # Replace the full registry path (hostname + any path prefix) with target registry, | ||
| # preserving only the last two path elements (org/image) and tag/digest |
There was a problem hiding this comment.
nit: Unlikely to happen with our current catalog index images, but what if we have a ref with no org (like just registry.example.com/plugin:1.9). I suspect this may not work as expected. Anyway, I guess it is fine as it might be an edge case.
43f3396
into
redhat-developer:release-1.9



PR Summary by Qodo
Fix mirror-plugins OCI rewrite for registries with path prefixes
🐞 Bug fix🕐 20-40 MinutesWalkthroughs
User Description
Description
Fixes OCI URL corruption in
mirror-plugins.shwhen the target registry includes a path prefix (e.g., JFrog Artifactory with artifactory.example.com/ocp). Thesedandjqregexes that rewrite OCI URLs in the catalog index only matched the hostname portion ([^/]+), treating everything after the first/as the image path. When--to-registryincludes a path prefix, each re-run of the script stacks the prefix:Run 1: oci://artifactory.example.com/ocp/rhdh/plugin-catalog-index:1.9 ✓ correct
Run 2: oci://artifactory.example.com/ocp/ocp/rhdh/plugin-catalog-index:1.9 ✗ stacked
Run 3: oci://artifactory.example.com/ocp/ocp/ocp/rhdh/plugin-catalog-index:1.9 ✗ worse
This PR updates all 6 regexes to match the full registry reference (hostname + any path prefix segments) instead of just the hostname, preserving only the last two path elements (org/image) and the tag/digest. The fix is idempotent re-running produces identical output.
Which issue(s) does this PR fix or relate to
PR acceptance criteria
How to test changes / Special notes to the reviewer
AI Description
Diagram
graph TD A["mirror-plugins.sh"] --> B{{"Extract catalog index"}} --> C[("index.json")] C --> D{{"Rewrite OCI refs (jq/sed)"}} --> E[("dynamic-plugins + entities")] E --> F{{"Rebuild & push index"}} --> G["Target registry"] subgraph Legend direction LR _script["Script"] ~~~ _step{{"Step/Tool"}} ~~~ _file[("File")] endHigh-Level Assessment
The following are alternative approaches to this PR:
1. Parse and reconstruct refs by splitting (no regex)
2. Use purpose-built tooling (yq/jq-only or small helper program)
Recommendation: Current approach is appropriate for a scoped bash-script fix: updating the jq/sed patterns to match the full registry reference (including optional path prefixes) directly addresses the idempotency bug without introducing new dependencies. If future edge cases emerge (digest formats, unusual repo names), consider refactoring into split/reconstruct logic or a small helper to avoid further regex growth.
File Changes
Bug fix (1)