feat: add --config flag support for oras attach#2000
Open
ogulcanaydogan wants to merge 1 commit intooras-project:mainfrom
Open
feat: add --config flag support for oras attach#2000ogulcanaydogan wants to merge 1 commit intooras-project:mainfrom
ogulcanaydogan wants to merge 1 commit intooras-project:mainfrom
Conversation
Add support for customizing the config descriptor when using oras attach, matching the existing --config flag behavior in oras push. This allows users to specify a config file with an optional media type using the format --config <file>[:<type>]. - Add manifestConfigRef field and --config flag to attach command - Parse config file reference and set ConfigDescriptor in pack options - Add config and platform mutual exclusivity validation - Add config annotations support for attach - Add usage example in command help text Fixes oras-project#1146 Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
7ea49c2 to
7e50d81
Compare
TerryHowe
requested changes
Mar 9, 2026
Member
TerryHowe
left a comment
There was a problem hiding this comment.
This could use some tests. It may be easier to add to test/e2e/suite/command/attach.go rather than unit tests
|
|
||
| packOpts := oras.PackManifestOptions{ | ||
| Subject: &subject, | ||
| ConfigAnnotations: opts.Annotations[option.AnnotationConfig], |
Member
There was a problem hiding this comment.
Seems like this annotation should only be set if opts.manifestConfigRef != ""
| } | ||
|
|
||
| cmd.Flags().StringVarP(&opts.artifactType, "artifact-type", "", "", "artifact type") | ||
| cmd.Flags().StringVarP(&opts.manifestConfigRef, "config", "", "", "`path` of image config file") |
Member
There was a problem hiding this comment.
Is push like this where it doesn't talk about file[:<type>]?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
--config <file>[:<type>]flag support tooras attach, matching the existing behavior inoras push. This allows users to customize the config descriptor (media type and content) when attaching artifacts to a subject.Use case: OCI does not mandate config content for artifacts, so users may need to define custom config data with specific media types when attaching artifacts.
Changes
cmd/oras/root/attach.go:manifestConfigReffield toattachOptionsstruct--configflag with path format<file>[:<type>]fileref.Parse()and add to file storeConfigDescriptorandConfigAnnotationsinPackManifestOptions--configand--platformflagsUsage
# Attach with custom config file and media type oras attach --artifact-type doc/example \ --config config.json:application/vnd.me.config \ localhost:5000/hello:v1 hi.txtTest plan
go build ./cmd/oras/— builds successfullygo vet ./cmd/oras/...— no issuesgo test ./...— full test suite passes (all packages OK)Fixes #1146