Skip to content

cmd/oras/root/attach: pass --annotation $config:* through to PackManifestOptions#2037

Open
SAY-5 wants to merge 1 commit intooras-project:mainfrom
SAY-5:fix/attach-config-annotations-2022
Open

cmd/oras/root/attach: pass --annotation $config:* through to PackManifestOptions#2037
SAY-5 wants to merge 1 commit intooras-project:mainfrom
SAY-5:fix/attach-config-annotations-2022

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 22, 2026

Summary

Fixes #2022.

runAttach built oras.PackManifestOptions without a ConfigAnnotations entry, so --annotation $config:key=val was silently dropped whenever the user did not also pass --config: oras-go generated the default config descriptor and never saw the annotations. runPush already wires ConfigAnnotations unconditionally, 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/... clean
  • go vet ./cmd/oras/... clean
  • go test ./cmd/oras/... ./internal/... green
  • Manual: oras attach --artifact-type doc/example --annotation '$config:org.example.key=value' localhost:5000/hello:v1 hi.txt produces a manifest whose config descriptor carries {"org.example.key": "value"}.

…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 <SAY-5@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

oras attach ignores --annotation $config:key=val when --config is not provided

1 participant