Skip to content

refactor: ApplyFlags with prefix for Remote and Target#1733

Merged
shizhMSFT merged 1 commit into
oras-project:mainfrom
TerryHowe:refactor-apply-flags
Jul 10, 2025
Merged

refactor: ApplyFlags with prefix for Remote and Target#1733
shizhMSFT merged 1 commit into
oras-project:mainfrom
TerryHowe:refactor-apply-flags

Conversation

@TerryHowe

Copy link
Copy Markdown
Member

What this PR does / why we need it:

It kind of looks like this Target/Remote code was in the middle of some refactor that was never completed. This doesn't address all the issues, but it does clean up flag/prefix/description handling a bit.

@Wwwsylvia

Copy link
Copy Markdown
Member

The E2E test failed, oops

@qweeah

qweeah commented May 26, 2025

Copy link
Copy Markdown
Contributor

This PR breaks oras login. All remote option flags are gone.

@qweeah

qweeah commented May 26, 2025

Copy link
Copy Markdown
Contributor

This PR breaks oras login. All remote option flags are gone.

That's why the E2E fails initialization.

Comment thread cmd/oras/internal/option/remote.go
@TerryHowe TerryHowe force-pushed the refactor-apply-flags branch 4 times, most recently from 1944119 to 5b8a84f Compare June 12, 2025 18:40
@codecov

codecov Bot commented Jun 12, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.39%. Comparing base (1e685f5) to head (00e5c86).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1733      +/-   ##
==========================================
- Coverage   85.43%   85.39%   -0.04%     
==========================================
  Files         137      137              
  Lines        5951     5950       -1     
==========================================
- Hits         5084     5081       -3     
- Misses        616      618       +2     
  Partials      251      251              

☔ 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.

@TerryHowe

Copy link
Copy Markdown
Member Author

Fixed this a while back

Comment thread cmd/oras/internal/option/remote.go Outdated
@TerryHowe TerryHowe force-pushed the refactor-apply-flags branch 2 times, most recently from b2647cd to 03768fe Compare July 4, 2025 14:41
@Wwwsylvia Wwwsylvia requested a review from Copilot July 7, 2025 02:22

Copilot AI 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.

Pull Request Overview

This PR refactors flag registration for Target, Remote, and related types to centralize prefix and description handling, and adds a test for conflicting OCI layout flags.

  • Introduces setFlagDetails on Target to set prefix/description before ApplyFlags
  • Updates Remote.ApplyFlagsWithPrefix to guard duplicate flags and use description
  • Refactors BinaryTarget to use the new Target prefix API and adds a new unit test

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cmd/oras/internal/option/target.go Removed old applyFlagsWithPrefix, added setFlagDetails and updated ApplyFlags call
cmd/oras/internal/option/remote.go Dropped applyPrefix, added fs.Lookup guards, switched to description
cmd/oras/internal/option/spec.go Simplified prefix usage in ApplyFlagsWithPrefix
cmd/oras/internal/option/binary_target.go Switched to setFlagDetails + ApplyFlags for From/To
cmd/oras/internal/option/target_test.go Added TestTarget_Parse_to_oci_and_oci_path

Comment thread cmd/oras/internal/option/target.go
Comment thread cmd/oras/internal/option/remote.go Outdated
@TerryHowe TerryHowe force-pushed the refactor-apply-flags branch from 03768fe to 532b045 Compare July 7, 2025 15:48
Comment thread cmd/oras/internal/option/binary_target.go Outdated
@TerryHowe TerryHowe force-pushed the refactor-apply-flags branch from 532b045 to ffff703 Compare July 8, 2025 13:34

@Wwwsylvia Wwwsylvia 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/option/target.go

@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 force-pushed the refactor-apply-flags branch from ffff703 to cb26304 Compare July 10, 2025 01:18
Signed-off-by: Terry Howe <terrylhowe@gmail.com>
@shizhMSFT shizhMSFT force-pushed the refactor-apply-flags branch from cb26304 to 00e5c86 Compare July 10, 2025 01:21
@shizhMSFT shizhMSFT merged commit 9440809 into oras-project:main Jul 10, 2025
8 checks passed
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.

5 participants