Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add handlers to manifest push commmand #1555

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

wangxiaoxuan273
Copy link
Contributor

@wangxiaoxuan273 wangxiaoxuan273 commented Nov 29, 2024

What this PR does / why we need it:

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 2 commits November 29, 2024 15:51
@wangxiaoxuan273 wangxiaoxuan273 changed the title Push handler refactor: add handlers to manifest push commmand Nov 29, 2024
Copy link

codecov bot commented Nov 29, 2024

Codecov Report

Attention: Patch coverage is 85.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 84.06%. Comparing base (ae989e8) to head (4cba0a4).

Files with missing lines Patch % Lines
cmd/oras/root/manifest/push.go 40.00% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1555      +/-   ##
==========================================
- Coverage   84.07%   84.06%   -0.02%     
==========================================
  Files         119      119              
  Lines        5325     5353      +28     
==========================================
+ Hits         4477     4500      +23     
- Misses        602      606       +4     
- Partials      246      247       +1     

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

Signed-off-by: Xiaoxuan Wang <[email protected]>
@wangxiaoxuan273 wangxiaoxuan273 marked this pull request as ready for review December 3, 2024 02:21
@qweeah
Copy link
Contributor

qweeah commented Dec 3, 2024

@wangxiaoxuan273 Can you help resolve the conflict?

Xiaoxuan Wang added 3 commits December 3, 2024 10:56
Signed-off-by: Xiaoxuan Wang <[email protected]>
Signed-off-by: Xiaoxuan Wang <[email protected]>
Signed-off-by: Xiaoxuan Wang <[email protected]>
cmd/oras/internal/display/status/interface.go Outdated Show resolved Hide resolved
cmd/oras/internal/display/status/text.go Outdated Show resolved Hide resolved
cmd/oras/internal/display/handler.go Outdated Show resolved Hide resolved
OnManifestExists(desc ocispec.Descriptor) error
OnManifestUploading(desc ocispec.Descriptor) error
OnManifestUploaded(desc ocispec.Descriptor) error
OnManifestPushed(ref string) error
Copy link
Contributor

Choose a reason for hiding this comment

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

This should belong to the metadata handler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed when doing oras manifest index create handlers, this function should be in status handler, as its output is like Pushed [registry] test.registry.io/test:v1. See this comment: #1509 (comment)

However, we may also need OnManifestPushed in metadata handler to output necessary metadata information. Future discussion may be needed.

In oras attach and oras push commands, this function is currently in metadata handler. We may need to move them to status handler in a future work item. cc: @shizhMSFT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to discuss more on the effect of tty handlers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideal handler workflows:

  1. Start operation (status)
  2. Process nodes / tasks (status, metadata); Note: For each node, we have status and metadata
    a. Start Processing (status)
    b. Complete processing (status, metadata)
  3. Complete operation (status, metadata)

Copy link
Contributor

Choose a reason for hiding this comment

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

Per offline discussion, we don't implement status update for "3. complete operation". Thus, we will drop OnManifestPushed. We will still keep OnManifestUploaded as the completion of the sub-task/sub-process. For naming convension, it is suggested to rename OnManifestUploaded to OnManifestPushed.

Copy link
Contributor

Choose a reason for hiding this comment

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

For metadata, we need OnManifestPushed (or equivalent) for the record of sub-task/sub-process and OnComplete for the record of completion of operation (mainly for rendering if the output format does not support streaming. e.g. JSON).

cmd/oras/root/manifest/push.go Outdated Show resolved Hide resolved
cmd/oras/internal/display/status/interface.go Outdated Show resolved Hide resolved
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.

Please follow @qweeah's comments

Xiaoxuan Wang added 4 commits December 4, 2024 10:56
Signed-off-by: Xiaoxuan Wang <[email protected]>
Signed-off-by: Xiaoxuan Wang <[email protected]>
Signed-off-by: Xiaoxuan Wang <[email protected]>
cmd/oras/internal/display/handler.go Show resolved Hide resolved
cmd/oras/internal/display/metadata/text/manifest_push.go Outdated Show resolved Hide resolved
cmd/oras/internal/display/metadata/text/manifest_push.go Outdated Show resolved Hide resolved
}

// OnCompleted implements metadata.ManifestPushHandler.
func (h *ManifestPushHandler) OnCompleted(desc ocispec.Descriptor) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (h *ManifestPushHandler) OnCompleted(desc ocispec.Descriptor) error {
func (h *ManifestPushHandler) OnCompleted() error {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to offline discussion, OnCompleted should have no parameters. Created #1573

cmd/oras/internal/display/status/utils.go Outdated Show resolved Hide resolved
Xiaoxuan Wang added 2 commits December 6, 2024 11:22
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.

4 participants