Skip to content

fix: print the format in the discover --output deprecation message - #2297

Merged
TerryHowe merged 1 commit into
oras-project:mainfrom
ogulcanaydogan:fix/discover-output-deprecation-format
Oct 24, 2026
Merged

TerryHowe merged 1 commit into
oras-project:mainfrom
ogulcanaydogan:fix/discover-output-deprecation-format

Conversation

@ogulcanaydogan

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

The deprecation message of oras discover -o/--output used opts.Template, which is only set for the go-template format, so it suggested --format with an empty value for tree, table and json:

[DEPRECATED] --output is deprecated, try `--format ` instead

It now prints the parsed format type (opts.Format.Type), for example --format json. The new test TestDiscoverCmd_OutputDeprecationMessage runs the command's PreRunE for each of the three formats and checks the message on stderr. It fails without the change.

Which issue(s) this PR fixes:
Fixes #2296

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?

The deprecation message used opts.Template, which is only set for the
go-template format, so "oras discover -o json" suggested "--format "
with an empty value. Use the parsed format type instead.

Signed-off-by: Ogulcan Aydogan <[email protected]>
@codecov

codecov Bot commented Oct 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.85%. Comparing base (e84a5d3) to head (d35e460).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2297      +/-   ##
==========================================
+ Coverage   60.95%   61.85%   +0.90%     
==========================================
  Files         140      140              
  Lines        6098     6098              
==========================================
+ Hits         3717     3772      +55     
+ Misses       2161     2102      -59     
- Partials      220      224       +4     

☔ View full report in Codecov by Harness.
📢 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.

@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

@TerryHowe
TerryHowe merged commit bc7b32d into oras-project:main Oct 24, 2026
10 checks passed
@TerryHowe TerryHowe mentioned this pull request Nov 17, 2026
4 tasks done
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.

discover: --output deprecation message suggests an empty --format

2 participants