feat: add --config flag support for oras attach#2000
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
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
Additional details and impacted files@@ Coverage Diff @@
## main #2000 +/- ##
==========================================
+ Coverage 87.15% 87.18% +0.03%
==========================================
Files 138 138
Lines 5448 5462 +14
==========================================
+ Hits 4748 4762 +14
Misses 419 419
Partials 281 281 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
looks like the last commit is missing signoff |
5df9bab to
2989670
Compare
|
All commits have DCO sign-off and CI is green. Ready to merge when you have a moment — thanks @TerryHowe! |
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>
Cover --config and --platform mutual exclusion and flag registration to improve patch coverage for the new flag. Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
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). Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
2989670 to
4a77777
Compare
|
Rebased onto main — all checks green, DCO clean. Ready to merge when you have a moment, @TerryHowe. |
Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
|
CI runs need maintainer approval to execute (fork PR restriction). @TerryHowe if you can approve the workflow runs, that should unblock the merge. |
|
Friendly bump — CI is green and all feedback has been addressed. |
|
Thanks! |
Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com> Co-authored-by: Terry Howe <terrylhowe@gmail.com>
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