Skip to content

feat: support version aliasing in CTF index#2136

Merged
jakobmoellerdev merged 1 commit into
open-component-model:mainfrom
chrisbleyerSAP:ctf-version-aliasing
Apr 1, 2026
Merged

feat: support version aliasing in CTF index#2136
jakobmoellerdev merged 1 commit into
open-component-model:mainfrom
chrisbleyerSAP:ctf-version-aliasing

Conversation

@chrisbleyerSAP

Copy link
Copy Markdown
Contributor

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

  • 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: #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.

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>
@chrisbleyerSAP chrisbleyerSAP requested a review from a team as a code owner April 1, 2026 09:38
@github-actions github-actions Bot added the kind/feature new feature, enhancement, improvement, extension label Apr 1, 2026
@coderabbitai

coderabbitai Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Updated AddArtifact method logic to handle multiple index entries sharing the same digest across different tags, implementing three distinct handling strategies: skipping exact duplicates, retagging when the same tag points to different digests, and filling empty tags on matching repository+digest entries. Added comprehensive test coverage for these behaviors and persistence across encode/decode cycles.

Changes

Cohort / File(s) Summary
Index Artifact Logic and Tests
bindings/go/ctf/index/v1/index.go, bindings/go/ctf/index/v1/index_test.go
Updated AddArtifact control flow to distinguish exact duplicates, implement retag semantics for conflicting tags, and support multiple tags per digest. Added 6 new test cases covering multi-tag same-digest behavior, deduplication, repository isolation, encode/decode persistence, retagging workflows, and untagged artifact handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A rabbit's ode to tagged treasures
Multiple tags now dance with glee,
Same digest, different identity!
Old tags clear when new ones arrive,
Empty tags at last come alive—
Our index hops with logic so fine,
Every artifact finding its shine! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title mentions 'version aliasing' which is the feature goal, but the actual changes are specifically about reworking the AddArtifact logic to support multiple tags per digest. While related to version aliasing, the title does not clearly summarize the main technical change in the changeset.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the CTF index modifications, specific behaviors implemented (exact duplicates, retagging, tagging untagged entries), and the addition of comprehensive tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the size/m Medium label Apr 1, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 865d043 and 2eefcc7.

📒 Files selected for processing (2)
  • bindings/go/ctf/index/v1/index.go
  • bindings/go/ctf/index/v1/index_test.go

Comment thread bindings/go/ctf/index/v1/index.go
@jakobmoellerdev jakobmoellerdev merged commit e2b46f9 into open-component-model:main Apr 1, 2026
16 checks passed
@chrisbleyerSAP chrisbleyerSAP deleted the ctf-version-aliasing branch April 2, 2026 06:41
@coderabbitai coderabbitai Bot mentioned this pull request Apr 2, 2026
frewilhelm added a commit to frewilhelm/open-component-model that referenced this pull request Apr 7, 2026
frewilhelm added a commit to frewilhelm/open-component-model that referenced this pull request Apr 7, 2026
frewilhelm added a commit to frewilhelm/open-component-model that referenced this pull request Apr 7, 2026
frewilhelm added a commit to frewilhelm/open-component-model that referenced this pull request Apr 7, 2026
frewilhelm added a commit to frewilhelm/open-component-model that referenced this pull request Apr 7, 2026
frewilhelm added a commit to frewilhelm/open-component-model that referenced this pull request Apr 7, 2026
morri-son pushed a commit to morri-son/open-component-model that referenced this pull request Apr 14, 2026
## 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>
morri-son pushed a commit to morri-son/open-component-model that referenced this pull request Apr 15, 2026
## 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature new feature, enhancement, improvement, extension size/m Medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants