Repository navigation
cmd/oras/root/attach: pass --annotation $config:* through to PackManifestOptions - #2037
Conversation
TerryHowe
left a comment
There was a problem hiding this comment.
Is there any way to add a test for this?
|
Added a unit test: |
|
Extracted |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2037 +/- ##
=======================================
Coverage 87.22% 87.22%
=======================================
Files 138 138
Lines 5462 5465 +3
=======================================
+ Hits 4764 4767 +3
Misses 417 417
Partials 281 281 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
uggh, lint error. Please rebase too. |
…festOptions runAttach built PackManifestOptions without ConfigAnnotations, so users who supplied --annotation $config:key=val (and no explicit --config flag) saw their config annotations silently dropped: oras-go generated the default config descriptor with no annotations. The push subcommand already sets ConfigAnnotations unconditionally, so this is strictly an attach-path regression; the field is harmless when the user didn't pass any $config annotations (the map lookup returns nil). Wire ConfigAnnotations alongside the existing ManifestAnnotations entry. Fixes oras-project#2022 Signed-off-by: SAY-5 <[email protected]>
Signed-off-by: Sai Asish Y <[email protected]>
…ns wiring Signed-off-by: say <[email protected]>
Signed-off-by: Sai Asish Y <[email protected]>
8439aa7 to
830de03
Compare
|
Rebased onto main and dropped the explicit |
|
Thanks! |
…festOptions (oras-project#2037) Signed-off-by: SAY-5 <[email protected]> Signed-off-by: Sai Asish Y <[email protected]> Signed-off-by: say <[email protected]> Co-authored-by: SAY-5 <[email protected]>
Summary
Fixes #2022.
runAttachbuiltoras.PackManifestOptionswithout aConfigAnnotationsentry, so--annotation $config:key=valwas silently dropped whenever the user did not also pass--config: oras-go generated the default config descriptor and never saw the annotations.runPushalready wiresConfigAnnotationsunconditionally, so this was strictly an attach-path oversight.Fix
Add the same
ConfigAnnotations: opts.Annotations[option.AnnotationConfig]line to the attach packOpts. When the caller did not pass any$config:*annotations the map lookup returns nil and PackManifest keeps its current default-config behaviour.Test plan
go build ./cmd/oras/...cleango vet ./cmd/oras/...cleango test ./cmd/oras/... ./internal/...greenoras attach --artifact-type doc/example --annotation '$config:org.example.key=value' localhost:5000/hello:v1 hi.txtproduces a manifest whose config descriptor carries{"org.example.key": "value"}.