feat: add --config flag support for oras attach#2000
feat: add --config flag support for oras attach#2000ogulcanaydogan wants to merge 4 commits intooras-project:mainfrom
Conversation
7ea49c2 to
7e50d81
Compare
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
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>
Add e2e tests covering: - attach with custom config file (default media type) - attach with custom config file and custom media type - --config and --platform mutual exclusivity failure Also fix ConfigAnnotations being set unconditionally on PackManifestOptions: move it inside the manifestConfigRef check so it only applies when a config file is actually provided. Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
c88cae7 to
4c75f97
Compare
|
Rebased onto latest main (as of today). All previous review comments have been addressed:
@TerryHowe ready for re-review when you have a chance, thank you! |
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (71.42%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #2000 +/- ##
==========================================
- Coverage 87.18% 87.14% -0.04%
==========================================
Files 143 143
Lines 5539 5553 +14
==========================================
+ Hits 4829 4839 +10
- Misses 423 425 +2
- Partials 287 289 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Cover --config and --platform mutual exclusion and flag registration to improve patch coverage for the new flag.
Add e2e tests that exercise the error paths introduced by the --config flag: empty file path (fileref.Parse error) and non-existent config file (addFile error).
|
looks like the last commit is missing signoff |
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