Skip to content

Conversation

wangxiaoxuan273
Copy link
Contributor

@wangxiaoxuan273 wangxiaoxuan273 commented Feb 10, 2025

What this PR does / why we need it:

The oras blob push on the main branch has several problems.

  1. It uses Printer.Println for status and metadata output, instead of handlers.
  2. When pushing a blob that already exists, tty tracking is not used.
  3. When --descriptor is used, status output is still shown but nothing should be printed except the descriptor.

This PR fixes all the above issues and refactors the code to use status, metadata and content handlers.

Current display:
image

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

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?

Xiaoxuan Wang added 4 commits December 5, 2024 13:44
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Copy link

codecov bot commented Feb 10, 2025

Codecov Report

Attention: Patch coverage is 82.60870% with 16 lines in your changes missing coverage. Please review.

Project coverage is 84.33%. Comparing base (d556dff) to head (2d26209).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/oras/root/blob/push.go 72.72% 3 Missing and 3 partials ⚠️
cmd/oras/internal/display/status/tty.go 80.76% 4 Missing and 1 partial ⚠️
cmd/oras/internal/display/handler.go 62.50% 2 Missing and 1 partial ⚠️
cmd/oras/internal/display/metadata/discard.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1618      +/-   ##
==========================================
+ Coverage   84.31%   84.33%   +0.01%     
==========================================
  Files         121      122       +1     
  Lines        5566     5630      +64     
==========================================
+ Hits         4693     4748      +55     
- Misses        619      627       +8     
- Partials      254      255       +1     

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

Xiaoxuan Wang and others added 9 commits February 10, 2025 16:04
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
@wangxiaoxuan273 wangxiaoxuan273 marked this pull request as ready for review February 17, 2025 06:47
@wangxiaoxuan273 wangxiaoxuan273 changed the title [WIP] refactor: use handlers for oras blob push command refactor: use handlers for oras blob push command Feb 17, 2025
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Copy link
Member

@Wwwsylvia Wwwsylvia left a comment

Choose a reason for hiding this comment

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

LGTM

@shizhMSFT
Copy link
Contributor

Since #1524 does major refactoring on the status output, let's wait #1524 to be merged first.

Xiaoxuan Wang added 2 commits February 20, 2025 16:05
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Xiaoxuan Wang added 2 commits February 20, 2025 16:19
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM with suggestions. Nice catch on the Exists UI bug.

@shizhMSFT shizhMSFT requested a review from Wwwsylvia February 20, 2025 15:23
Xiaoxuan Wang added 2 commits February 25, 2025 14:41
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
Copy link
Member

@Wwwsylvia Wwwsylvia left a comment

Choose a reason for hiding this comment

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

LGTM

@Wwwsylvia Wwwsylvia merged commit 059406b into oras-project:main Feb 25, 2025
8 checks passed
@wangxiaoxuan273 wangxiaoxuan273 deleted the blob-push-handler branch August 25, 2025 02:59
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.

3 participants