-
Notifications
You must be signed in to change notification settings - Fork 201
feat!: refine oras discover JSON format #1649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: refine oras discover JSON format #1649
Conversation
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1649 +/- ##
=======================================
Coverage 84.52% 84.53%
=======================================
Files 126 126
Lines 5681 5682 +1
=======================================
+ Hits 4802 4803 +1
Misses 625 625
Partials 254 254 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR updates the output of the oras discover command when using JSON and go-template formats by including a dedicated subject field and renaming the existing manifests field to referrers. The changes affect tests, command help text, metadata models, and related helper functions to support the new structure.
- Updated test expectations to unmarshal into a new structure with Subject and Referrers.
- Modified CLI examples and internal model functions to align with the new JSON format.
- Adjusted multiple e2e tests to validate the updated discover output across different outputs (json, tree, table, etc).
Reviewed Changes
File | Description |
---|---|
test/e2e/suite/command/discover.go | Replaced references to "manifests" with a new "discover" struct containing Subject and Referrers. |
test/e2e/internal/testdata/foobar/const.go | Added new descriptor constants (FooBar, FooBarOCI) for subject manifest support. |
cmd/oras/root/discover.go | Updated CLI help examples to use the new referrers field in go-template output. |
cmd/oras/internal/display/metadata/model/discover.go | Changed model structure and NewDiscover signature to include subject and referrers instead of manifests. |
test/e2e/suite/command/resolve_host.go, cp.go, attach.go, oci_artifact.go | Adjusted tests to reference the new referrers field consistently across JSON and go-template outputs. |
cmd/oras/internal/display/metadata/template/discover.go and json/discover.go | Updated construction of discover models to pass subject information appropriately. |
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
test/e2e/suite/command/discover.go:110
- [nitpick] The struct name 'discover' is very generic and is repeatedly defined across multiple test files. Consider renaming it or extracting it into a common helper to improve maintainability.
type discover struct {
test/e2e/suite/command/discover.go:131
- [nitpick] While JSON output tests validate the subject field, consider adding tests for non-JSON outputs (e.g., tree and table) to ensure that the subject information is consistently conveyed.
It("should include information of subject and referrers manifests", func() {
aad8926
to
2c6676b
Compare
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
d5c8168
to
169bc35
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the output of the oras discover command to include the subject manifest and renames the output field from "manifests" to "referrers" when using the JSON format. Key changes include:
- Updating tests and examples to expect a subject descriptor and referrers field.
- Changing the underlying model and template implementations to replace "manifests" with "referrers".
- Adjusting go-template examples and related E2E tests to reflect the renamed field.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
test/e2e/suite/command/discover.go | Updated JSON parsing in tests to check "referrers" instead of "manifests" and include subject validation. |
test/e2e/internal/testdata/foobar/const.go | Added new descriptor constants for subject manifests. |
cmd/oras/root/discover.go | Updated go-template example to output "referrers". |
cmd/oras/internal/display/metadata/model/discover.go | Updated model to accept a subject and referrers, and renamed JSON key. |
test/e2e/suite/command/cp.go | Updated tests to verify output based on "referrers" field. |
test/e2e/suite/command/resolve_host.go | Updated tests to check the new JSON field "referrers". |
test/e2e/suite/command/attach.go | Adjusted attachment tests to output and verify using "referrers". |
test/e2e/suite/scenario/oci_artifact.go | Updated artifact tests to use "referrers" in go-template output. |
cmd/oras/internal/display/metadata/json/discover.go | Updated JSON discover handler to pass the subject manifest. |
cmd/oras/internal/display/metadata/template/discover.go | Updated template discover handler accordingly. |
Comments suppressed due to low confidence (1)
test/e2e/suite/command/discover.go:110
- [nitpick] Consider extracting the repeated inline 'discover' struct definition into a shared test helper to improve maintainability and consistency across tests.
type discover struct {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Spec related: #1625 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but this PR depends on #1625
@shizhMSFT @wangxiaoxuan273 @oras-project/oras-cli You can review this PR now #1625 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What this PR does / why we need it:
This Pull Request:
oras discover
when using the--format json
option.manifests
toreferrers
.Current display:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Part of #1403
Please check the following list: