Skip to content

chore(ux): improve error output for unknown spec flag#1221

Merged
qweeah merged 19 commits into
oras-project:mainfrom
qweeah:spec-error
Dec 29, 2023
Merged

chore(ux): improve error output for unknown spec flag#1221
qweeah merged 19 commits into
oras-project:mainfrom
qweeah:spec-error

Conversation

@qweeah

@qweeah qweeah commented Dec 27, 2023

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
This PR improves error output of invalid spec option and fixes #1217

  • The parsing of --image-spec and --distribution-spec were refactored into native pflag parsing
  • changed the output of invalid value for both flags to
    $ oras attach --distribution-spec 123
    Error: invalid argument "123" for "--distribution-spec" flag: unknown distribution 
    specification flag: 123
    Available options: v1.1-referrers-tag, v1.1-referrers-api
    $ oras push --image-spec 123      
    Error: invalid argument "123" for "--image-spec" flag: unknown image specification flag: 123
    Available options: v1.1, v1.0

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>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
@qweeah qweeah marked this pull request as draft December 27, 2023 08:46
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-commenter

codecov-commenter commented Dec 27, 2023

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c1a3185) 79.89% compared to head (c12f05c) 80.10%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1221      +/-   ##
==========================================
+ Coverage   79.89%   80.10%   +0.21%     
==========================================
  Files          67       67              
  Lines        3695     3719      +24     
==========================================
+ Hits         2952     2979      +27     
+ Misses        524      522       -2     
+ Partials      219      218       -1     

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

@qweeah qweeah marked this pull request as ready for review December 27, 2023 12:37
Comment thread cmd/oras/internal/option/spec.go Outdated
Comment thread cmd/oras/internal/option/spec.go Outdated
Comment thread cmd/oras/internal/option/spec.go Outdated
Comment thread cmd/oras/internal/option/spec.go Outdated
Comment thread cmd/oras/internal/option/spec.go Outdated
Comment thread cmd/oras/internal/option/spec.go Outdated
Comment thread cmd/oras/internal/option/spec.go Outdated
Comment thread cmd/oras/internal/option/spec.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>
@qweeah qweeah marked this pull request as draft December 28, 2023 08:14
@qweeah qweeah marked this pull request as ready for review December 28, 2023 08:15
Comment thread cmd/oras/internal/option/spec.go
Comment thread cmd/oras/internal/option/spec.go Outdated
Comment thread cmd/oras/internal/option/spec.go Outdated
Comment thread cmd/oras/internal/option/spec.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>

@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

@qweeah qweeah merged commit f8be882 into oras-project:main Dec 29, 2023
FeynmanZhou pushed a commit to FeynmanZhou/oras that referenced this pull request May 11, 2024
)

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.

improve error message when invalid options given when pushing

3 participants