feat!: add digest support for component references#2086
Conversation
Signed-off-by: Fabian Burth <fabian.burth@sap.com>
Signed-off-by: Fabian Burth <fabian.burth@sap.com>
Signed-off-by: Fabian Burth <fabian.burth@sap.com>
|
Caution Review failedAn error occurred during the review process. Please try again later. 📝 WalkthroughWalkthroughAdds an optional Digest to references across spec/runtime/descriptor layers, propagates it through conversion helpers, implements digest verification during reference processing (new ErrDigestMismatch), and updates deep-copy logic and tests to handle the Digest field. Changes
Sequence Diagram(s)sequenceDiagram
participant Spec as Spec (v1)
participant Conv as Converter
participant Descriptor as Descriptor
participant Constructor as Constructor.Process
Spec->>Conv: ConvertToRuntimeReference (may include digest)
Conv->>Descriptor: ConvertToDescriptorReference (propagate digest)
Descriptor->>Constructor: processReference(descriptor.Reference)
Constructor->>Constructor: calculate digest from component
alt Provided digest present
Constructor->>Constructor: compare calculated vs provided digest
alt match
Constructor->>Constructor: set ref.Digest = calculated
else mismatch
Constructor-->>Constructor: return ErrDigestMismatch (wrapped)
end
end
Constructor->>Constructor: call OnEndReferenceConstruct hook (identity formatting adjusted)
Constructor-->>Descriptor: continue processing / return result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 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
🤖 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/construct.go`:
- Around line 352-359: When OnEndReferenceConstruct
(c.opts.OnEndReferenceConstruct) returns an error while there is already an
original reference error (err, e.g. ErrDigestMismatch from processReference),
preserve both by joining them instead of returning only the hook error; create a
combined error (use errors.Join(hookErr, err) or equivalent) and return it
wrapped with context in the fmt.Errorf call for the OnEndReferenceConstruct
failure for reference.ToIdentity(), so upstream errors.Is(err,
ErrDigestMismatch) still works; keep the existing separate check that returns
the processing error (the "error processing reference %q at index %d" branch)
when there is no hook error.
🪄 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: e4388fb5-0aee-47c5-a523-723f4ef3dc2c
📒 Files selected for processing (10)
bindings/go/constructor/construct.gobindings/go/constructor/runtime/constructor.gobindings/go/constructor/runtime/convert_desc.gobindings/go/constructor/runtime/convert_v1.gobindings/go/constructor/runtime/zz_generated.deepcopy.gobindings/go/constructor/spec/v1/constructor.gobindings/go/constructor/spec/v1/constructor_test.gobindings/go/constructor/spec/v1/convert.gobindings/go/constructor/spec/v1/resources/schema-2020-12.jsonbindings/go/constructor/spec/v1/zz_generated.deepcopy.go
Signed-off-by: Fabian Burth <fabian.burth@sap.com>
eb89216 to
f07e102
Compare
Signed-off-by: Fabian Burth <fabian.burth@sap.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/construct.go`:
- Around line 603-616: The current digest equality in construct.go treats any
non-nil reference.Digest as a complete triple and compares all three fields,
causing valid partial digests (e.g., only Value set) to incorrectly trigger
ErrDigestMismatch; update the logic in the function containing this block to
either (a) validate that a supplied reference.Digest is complete by explicitly
checking that HashAlgorithm, NormalisationAlgorithm and Value are all non-empty
and return a clear error if any are missing, or (b) perform per-field
comparisons only for fields that are populated on the incoming reference.Digest
(compare HashAlgorithm only if reference.Digest.HashAlgorithm != "", etc.) and
ignore unset fields when comparing against referencedComponentDigest; refer to
the symbols reference.Digest and referencedComponentDigest to locate and adjust
the equality check accordingly.
🪄 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: 678a8733-ac0d-4ee0-b4b3-058c95ffbad7
📒 Files selected for processing (2)
.gitignorebindings/go/constructor/construct.go
✅ Files skipped from review due to trivial changes (1)
- .gitignore
Signed-off-by: Fabian Burth <fabian.burth@sap.com>
…fy the reason Signed-off-by: Fabian Burth <fabian.burth@sap.com>
Description
Digestfield toReferencetype in constructor runtime and spec/v1 packagesDue to the changes to the schema (
additionalProperties: false), this can be considered a breaking change.Test plan
constructor_test.go