Skip to content

feat: const with reference digest#2084

Merged
jakobmoellerdev merged 9 commits into
open-component-model:mainfrom
fabianburth:feat/constructor-with-reference-digest
Mar 30, 2026
Merged

feat: const with reference digest#2084
jakobmoellerdev merged 9 commits into
open-component-model:mainfrom
fabianburth:feat/constructor-with-reference-digest

Conversation

@fabianburth

Copy link
Copy Markdown
Contributor

What this PR does / why we need it

We want to adopt the backwards compatible constructor json schema. This allows component references in the component constructor.

Which issue(s) this PR fixes

open-component-model/ocm-project#961

Testing

How to test the changes
Verification
  • I have tested the changes locally by running ocm

@fabianburth fabianburth requested a review from a team as a code owner March 27, 2026 11:02
@github-actions github-actions Bot added kind/feature new feature, enhancement, improvement, extension size/m Medium labels Mar 27, 2026
@coderabbitai

coderabbitai Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Added comprehensive test validation for component reference digest handling in the CLI, including success and failure scenarios. Updated Go module dependencies across multiple files, promoting golang.org/x/crypto to direct requirement in examples module and upgrading constructor binding versions.

Changes

Cohort / File(s) Summary
Test Coverage for Digest Validation
cli/cmd/cmd_test.go
Added new test Test_Add_Component_Version_With_Reference_Digest with 160 lines to validate digest handling when adding component versions, including both successful digest matching and failure cases with intentional digest mismatches.
Go Module Dependency Updates
cli/go.mod, cli/integration/go.mod
Upgraded ocm.software/open-component-model/bindings/go/constructor from v0.0.6 to v0.0.7 in both CLI and integration module files.
Example Module Dependency Reorganization
bindings/go/examples/go.mod
Restructured and expanded dependencies, moving golang.org/x/crypto v0.48.0 to direct requirements alongside oras.land/oras-go/v2 v2.6.0, and added multiple indirect dependencies including OCM-related modules (configuration v0.0.12 and dag v0.0.6) and container/observability libraries with version updates to opentelemetry and protobuf packages.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • frewilhelm
  • jakobmoellerdev

Poem

🐰 Hopping through tests with digest in sight,
Reference checks done wrong and right,
Dependencies bundled, versions aligned,
Component validation, perfectly designed! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% 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 'feat: const with reference digest' directly corresponds to the main change—adding support for reference digest handling in component constructor functionality.
Description check ✅ Passed The description explains the PR's purpose (adopting the backwards compatible constructor JSON schema to allow component references) and references the related issue, which aligns with the changes.

✏️ 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.

@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: 2

🧹 Nitpick comments (1)
cli/cmd/cmd_test.go (1)

1985-1987: Remove unused variable assignment.

The _ = referencedDesc assignment on line 1986 serves no purpose. The variable was used earlier to verify the referenced component exists but this final assignment is dead code.

🧹 Remove unused assignment
-	// Verify referenced component is still accessible
-	_ = referencedDesc
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cli/cmd/cmd_test.go` around lines 1985 - 1987, Remove the dead assignment "_
= referencedDesc" at the end of the test: the variable referencedDesc is already
used earlier to verify the referenced component, so delete the final no-op
assignment (search for referencedDesc in the test function in cmd_test.go and
remove the standalone "_ = referencedDesc" line) to eliminate the
unused-assignment noise and keep the test unchanged otherwise.
🤖 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/constructor/runtime/convert_desc.go`:
- Around line 202-210: ConvertFromDescriptorReference currently always
constructs a non-nil *Digest for the returned Reference which can break callers
that treat nil Digest as "not provided"; update the code in
ConvertFromDescriptorReference to only populate the Reference.Digest pointer
when the input reference.Digest is meaningful (non-nil and/or has non-empty
HashAlgorithm/NormalisationAlgorithm/Value) to mirror
ConvertToDescriptorReference behavior — leave Reference.Digest nil when the
descriptor contains a zero-value digest. Ensure you check the input
reference.Digest and only set the Digest fields (HashAlgorithm,
NormalisationAlgorithm, Value) into the new *Digest when at least one of those
fields is non-empty.

In `@bindings/go/constructor/spec/v1/resources/schema-2020-12.json`:
- Around line 398-400: The change adds "additionalProperties": false to the
"component" object schema which makes validation breaking for any existing
component objects with extra fields; revert this strictness by removing or
setting "additionalProperties" to true on the "component" definition or, if the
strict rule is intentional, document the breaking change and bump the
schema/contract version so consumers are aware; refer to the "component" schema
entry and the "additionalProperties" flag when making the update.

---

Nitpick comments:
In `@cli/cmd/cmd_test.go`:
- Around line 1985-1987: Remove the dead assignment "_ = referencedDesc" at the
end of the test: the variable referencedDesc is already used earlier to verify
the referenced component, so delete the final no-op assignment (search for
referencedDesc in the test function in cmd_test.go and remove the standalone "_
= referencedDesc" line) to eliminate the unused-assignment noise and keep the
test unchanged otherwise.
🪄 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: d4c7b6ae-2c29-4148-a1e5-93ebf3a5daa6

📥 Commits

Reviewing files that changed from the base of the PR and between 18fca4d and c0fce2b.

📒 Files selected for processing (9)
  • bindings/go/constructor/construct.go
  • bindings/go/constructor/runtime/constructor.go
  • bindings/go/constructor/runtime/convert_desc.go
  • bindings/go/constructor/runtime/convert_v1.go
  • bindings/go/constructor/spec/v1/constructor.go
  • bindings/go/constructor/spec/v1/constructor_test.go
  • bindings/go/constructor/spec/v1/convert.go
  • bindings/go/constructor/spec/v1/resources/schema-2020-12.json
  • cli/cmd/cmd_test.go

Comment thread bindings/go/constructor/runtime/convert_desc.go Outdated
Comment thread bindings/go/constructor/spec/v1/resources/schema-2020-12.json
Signed-off-by: Fabian Burth <fabian.burth@sap.com>
Signed-off-by: Fabian Burth <fabian.burth@sap.com>
@fabianburth

Copy link
Copy Markdown
Contributor Author

Unit test fail due to local go.work. Will run a manual ocm add cv to test the behaviour and then split the PR.

# Conflicts:
#	bindings/go/constructor/construct.go
Signed-off-by: Fabian Burth <fabian.burth@sap.com>
Signed-off-by: Fabian Burth <fabian.burth@sap.com>
piotrjanik
piotrjanik previously approved these changes Mar 27, 2026

@piotrjanik piotrjanik 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.

LGTMm, though docker.io rejects connection in actions. Rate limit?

@fabianburth fabianburth changed the title feat: constructor with reference digest feat: const with reference digest Mar 27, 2026
Signed-off-by: Fabian Burth <fabian.burth@sap.com>
@jakobmoellerdev jakobmoellerdev enabled auto-merge (squash) March 30, 2026 07:22
@jakobmoellerdev jakobmoellerdev merged commit 9dfd9a0 into open-component-model:main Mar 30, 2026
22 checks passed
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.

4 participants