Skip to content

chore(ux): improve error message when attaching without subject artifact #1430

Merged
qweeah merged 23 commits into
oras-project:mainfrom
qweeah:improve-attach
Jul 4, 2024
Merged

chore(ux): improve error message when attaching without subject artifact #1430
qweeah merged 23 commits into
oras-project:mainfrom
qweeah:improve-attach

Conversation

@qweeah

@qweeah qweeah commented Jun 24, 2024

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
This PR improves error message when the oras attach is run with only one argument, which might be an invalid artifact subject reference or mistakenly used as a to-be-uploaded file path.

Before

> oras attach --artifact-type test/example $ARTIFACT ./layers 
Error: neither file nor annotation provided in the command
Usage: oras attach [flags] --artifact-type=<type> <name>{:<tag>|@<digest>} <file>[:<layer_media_type>] [...]
To attach to an existing artifact, please provide files via argument or annotations via flag "--annotation". Run "oras attach -h" for more options and examples

After

> oras attach --artifact-type test/example $ARTIFACT ./layers 
Error: "./layers": no tag or digest specified
Usage: oras attach [flags] --artifact-type=<type> <name>{:<tag>|@<digest>} <file>[:<layer_media_type>] [...]
Have you specified an artifact reference to attach to? Please specify a reference in the form of "<name>:<tag>" or "<name>@<digest>". Run "oras attach -h" for more options and examples

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

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?

qweeah added 7 commits June 21, 2024 10:33
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>
@codecov

codecov Bot commented Jun 24, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.41%. Comparing base (e7ffb65) to head (e1163c7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1430      +/-   ##
==========================================
+ Coverage   85.38%   85.41%   +0.02%     
==========================================
  Files         108      108              
  Lines        3818     3825       +7     
==========================================
+ Hits         3260     3267       +7     
- Misses        333      334       +1     
+ Partials      225      224       -1     

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

qweeah added 3 commits June 24, 2024 00:54
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
@qweeah qweeah marked this pull request as ready for review June 24, 2024 01:06
@wangxiaoxuan273

Copy link
Copy Markdown
Contributor

LGTM but I'm not a maintainer

Comment thread cmd/oras/internal/errors/errors.go Outdated
Signed-off-by: Billy Zha <jinzha1@microsoft.com>

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

Comment thread cmd/oras/internal/errors/errors.go
Comment thread cmd/oras/internal/errors/errors.go Outdated
Comment thread cmd/oras/internal/errors/errors.go Outdated
Comment thread cmd/oras/internal/errors/errors.go Outdated
Comment thread cmd/oras/internal/errors/errors.go Outdated
Comment thread cmd/oras/internal/errors/errors.go Outdated
Comment thread cmd/oras/root/attach.go Outdated
Comment thread cmd/oras/root/attach.go Outdated

@FeynmanZhou FeynmanZhou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just one suggested error message for this case

qweeah added 5 commits June 28, 2024 08:14
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 with suggestions

Comment thread cmd/oras/root/attach.go Outdated
qweeah added 3 commits June 28, 2024 10:34
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>

@FeynmanZhou FeynmanZhou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@qweeah qweeah merged commit a4a4b33 into oras-project:main Jul 4, 2024
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.

improve error message of oras attach when subject artifact is not specified

5 participants