feat: support version aliasing in CTF index#2136
Conversation
Allow multiple entries with the same digest but different tags, matching OCI Image Layout semantics. Previously, AddArtifact would overwrite the tag on an existing entry with the same digest. Now: - Multiple entries with the same digest but different tags coexist - Exact duplicates (same repo+tag+digest) are skipped - Retagging (same tag, different digest) clears the old tag - Tagging an untagged entry updates it in place Includes comprehensive tests for the new behavior. Signed-off-by: Christoph Bleyer <christoph.bleyer@sap.com>
📝 WalkthroughWalkthroughUpdated Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
bindings/go/ctf/index/v1/index.go (1)
24-27: Document the untagged-to-tagged reuse case in the interface contract.The public contract calls out deduplication and retagging, but not the third behavior implemented below: reusing an existing untagged entry with the same repository and digest instead of appending a second record.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@bindings/go/ctf/index/v1/index.go` around lines 24 - 27, The interface comment for AddArtifact(a ArtifactMetadata) omits the "untagged-to-tagged reuse" behavior; update the docblock for AddArtifact to state that if an existing entry with the same repository and digest exists but has no tag (untagged), the implementation should reuse/update that entry rather than appending a new record, along with the already-documented behaviors (deduplication and retagging), and reference the ArtifactMetadata fields used to determine repository, tag, and digest.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@bindings/go/ctf/index/v1/index.go`:
- Around line 101-120: The AddArtifact logic currently returns immediately on an
exact duplicate match, which prevents finishing the scan and clearing stale
repo+tag entries; update the loop in AddArtifact to always scan all entries in
i.Artifacts before deciding to return or reuse an existing entry: record
exact-duplicate, retag, and untagged-match cases (use foundExact,
foundUntaggedMatch, and track idxOfExact/idxOfStaleTag) while iterating, perform
any stale-tag clearing (clear i.Artifacts[idxOfStaleTag].Tag) and tagging of an
untagged entry after the loop, and only then skip adding when an exact duplicate
was found (or reuse the tagged untagged entry if set).
---
Nitpick comments:
In `@bindings/go/ctf/index/v1/index.go`:
- Around line 24-27: The interface comment for AddArtifact(a ArtifactMetadata)
omits the "untagged-to-tagged reuse" behavior; update the docblock for
AddArtifact to state that if an existing entry with the same repository and
digest exists but has no tag (untagged), the implementation should reuse/update
that entry rather than appending a new record, along with the already-documented
behaviors (deduplication and retagging), and reference the ArtifactMetadata
fields used to determine repository, tag, and digest.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b06e965c-f88c-4c82-85c0-164cdc9fe3f0
📒 Files selected for processing (2)
bindings/go/ctf/index/v1/index.gobindings/go/ctf/index/v1/index_test.go
…odel#2136)" This reverts commit e2b46f9.
…model#2136)" This reverts commit d44289d.
…odel#2136)" This reverts commit e2b46f9.
…model#2136)" This reverts commit e24aa0a.
…odel#2136)" This reverts commit e2b46f9.
…model#2136)" This reverts commit 6cbc5b7.
## Summary This PR extracts and upstreams the CTF index changes from the broader version aliasing feature open-component-model#2049. It's part of this feature request open-component-model/ocm-project#720. ### Changes - **CTF index (`bindings/go/ctf/index/v1`)**: Reworked `AddArtifact` to match OCI Image Layout semantics — multiple entries with the same digest but different tags can now coexist. Previously, adding a new tag to an existing digest would overwrite the old tag. - Exact duplicates (same repo + tag + digest) are skipped - Retagging (same tag, different digest) clears the old tag - Tagging an untagged entry updates it in place - Added comprehensive tests covering multi-tag, deduplication, cross-repo isolation, and encode/decode round-tripping ### Context This is the foundational change for **version aliasing** (see draft PR: open-component-model#2049, which allows multiple OCI tags to reference the same component version. The remaining OCI repository, CTF store, and validation changes will follow in a separate PR once this lands and a new version of the CTF module is released. Signed-off-by: Christoph Bleyer <christoph.bleyer@sap.com> Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
## Summary This PR extracts and upstreams the CTF index changes from the broader version aliasing feature open-component-model#2049. It's part of this feature request open-component-model/ocm-project#720. ### Changes - **CTF index (`bindings/go/ctf/index/v1`)**: Reworked `AddArtifact` to match OCI Image Layout semantics — multiple entries with the same digest but different tags can now coexist. Previously, adding a new tag to an existing digest would overwrite the old tag. - Exact duplicates (same repo + tag + digest) are skipped - Retagging (same tag, different digest) clears the old tag - Tagging an untagged entry updates it in place - Added comprehensive tests covering multi-tag, deduplication, cross-repo isolation, and encode/decode round-tripping ### Context This is the foundational change for **version aliasing** (see draft PR: open-component-model#2049, which allows multiple OCI tags to reference the same component version. The remaining OCI repository, CTF store, and validation changes will follow in a separate PR once this lands and a new version of the CTF module is released. Signed-off-by: Christoph Bleyer <christoph.bleyer@sap.com> Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
Summary
This PR extracts and upstreams the CTF index changes from the broader version aliasing feature #2049. It's part of this feature request open-component-model/ocm-project#720.
Changes
bindings/go/ctf/index/v1): ReworkedAddArtifactto match OCI Image Layout semantics — multiple entries with the same digest but different tags can now coexist. Previously, adding a new tag to an existing digest would overwrite the old tag.Context
This is the foundational change for version aliasing (see draft PR: #2049, which allows multiple OCI tags to reference the same component version. The remaining OCI repository, CTF store, and validation changes will follow in a separate PR once this lands and a new version of the CTF module is released.