Skip to content

feat: support formatted output in oras attach and push#1237

Merged
shizhMSFT merged 63 commits into
oras-project:mainfrom
qweeah:format-push
Feb 1, 2024
Merged

feat: support formatted output in oras attach and push#1237
shizhMSFT merged 63 commits into
oras-project:mainfrom
qweeah:format-push

Conversation

@qweeah

@qweeah qweeah commented Jan 9, 2024

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
This PR introduces --format flag to command oras push and oras attach. UX would be like:

$  subject=`oras push localhost:5000/test:demo --format {{.Ref}}`
✓ Exists    application/vnd.oci.empty.v1+json                                                                                                                                                                                                              2/2  B 100.00%     0s
  └─ sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a
✓ Uploaded  application/vnd.oci.image.manifest.v1+json                                                                                                                                                                                                 535/535  B 100.00%     0s
  └─ sha256:277450c0be1aa8c684eeaa3fb128d3ac29c7c7e7add45971436b5bb785076abc
$ oras attach $subject --artifact-type test/example -a k=v --format json
✓ Exists    application/vnd.oci.empty.v1+json                                                                                                                                                                                                              2/2  B 100.00%     0s
  └─ sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a
✓ Uploaded  application/vnd.oci.image.manifest.v1+json                                                                                                                                                                                                 683/683  B 100.00%     0s
  └─ sha256:a3d50fbe69ca09d6b04a65262b33a6ec524e5d8c626b5f8378f329e605f8e53b
{
  "Ref": "localhost:5000/test@sha256:a3d50fbe69ca09d6b04a65262b33a6ec524e5d8c626b5f8378f329e605f8e53b",
  "MediaType": "application/vnd.oci.image.manifest.v1+json",
  "Digest": "sha256:a3d50fbe69ca09d6b04a65262b33a6ec524e5d8c626b5f8378f329e605f8e53b",
  "Size": 683,
  "URLs": null,
  "Annotations": {
    "k": "v",
    "org.opencontainers.image.created": "2024-01-09T09:01:11Z"
  },
  "Data": null,
  "Platform": null,
  "ArtifactType": ""
}%       

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Related to #638

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
@codecov

codecov Bot commented Jan 9, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.17647% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.97%. Comparing base (22c59ef) to head (9fd97e9).
⚠️ Report is 444 commits behind head on main.

Files with missing lines Patch % Lines
cmd/oras/root/push.go 46.15% 4 Missing and 3 partials ⚠️
cmd/oras/internal/display/handler.go 83.33% 2 Missing and 4 partials ⚠️
cmd/oras/internal/display/status/tty.go 83.33% 4 Missing and 2 partials ⚠️
cmd/oras/root/file.go 28.57% 3 Missing and 2 partials ⚠️
cmd/oras/internal/option/format.go 55.55% 3 Missing and 1 partial ⚠️
cmd/oras/root/manifest/push.go 20.00% 1 Missing and 3 partials ⚠️
...ras/internal/display/metadata/template/template.go 50.00% 2 Missing and 1 partial ⚠️
cmd/oras/internal/display/metadata/text/attach.go 76.92% 2 Missing and 1 partial ⚠️
cmd/oras/internal/display/status/text.go 92.10% 2 Missing and 1 partial ⚠️
cmd/oras/root/cp.go 57.14% 0 Missing and 3 partials ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1237      +/-   ##
==========================================
+ Coverage   81.35%   81.97%   +0.61%     
==========================================
  Files          68       83      +15     
  Lines        3825     3995     +170     
==========================================
+ Hits         3112     3275     +163     
+ Misses        500      497       -3     
- Partials      213      223      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

qweeah added 18 commits January 18, 2024 07:13
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Comment thread go.mod Outdated
Comment thread cmd/oras/internal/display/progress/status_test.go
Comment thread cmd/oras/internal/display/track/target_test.go
Comment thread cmd/oras/internal/display/print.go Outdated
Comment thread cmd/oras/internal/display/print.go Outdated
Comment thread cmd/oras/internal/option/format.go
Comment thread cmd/oras/internal/option/format.go Outdated
Comment thread cmd/oras/internal/option/format.go Outdated
Comment thread cmd/oras/internal/option/format.go Outdated
Comment thread cmd/oras/root/attach.go Outdated
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Comment thread cmd/oras/internal/display/metadata/interface.go Outdated
Comment thread cmd/oras/internal/display/metadata/json/push.go Outdated
Comment thread cmd/oras/internal/display/metadata/text/push.go Outdated
Comment thread cmd/oras/internal/option/format.go Outdated
Comment thread cmd/oras/internal/option/format.go Outdated
Signed-off-by: Billy Zha <jinzha1@microsoft.com>

@shizhMSFT shizhMSFT left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>

@shizhMSFT shizhMSFT left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: Billy Zha <jinzha1@microsoft.com>

@shizhMSFT shizhMSFT left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>

@shizhMSFT shizhMSFT left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shizhMSFT shizhMSFT left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shizhMSFT shizhMSFT merged commit da03b23 into oras-project:main Feb 1, 2024
FeynmanZhou pushed a commit to FeynmanZhou/oras that referenced this pull request May 11, 2024
…1237)

Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Feynman Zhou <feynmanzhou@microsoft.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.

2 participants