oras-project / oras

OCI registry client - managing content like artifacts, images, packages
https://oras.land
Apache License 2.0
1.33k stars 160 forks source link

refactor: Move printer to output package #1394

Closed TerryHowe closed 2 weeks ago

TerryHowe commented 1 month ago

What this PR does / why we need it:

The printer is supposed to be a very generic output object and this change moves in that direction.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.

Project coverage is 85.06%. Comparing base (8027e16) to head (c880581).

Files Patch % Lines
cmd/oras/root/cp.go 50.00% 0 Missing and 2 partials :warning:
cmd/oras/internal/display/status/text.go 66.66% 0 Missing and 1 partial :warning:
cmd/oras/internal/display/status/tty.go 0.00% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1394 +/- ## ======================================= Coverage 85.06% 85.06% ======================================= Files 107 107 Lines 3804 3804 ======================================= Hits 3236 3236 Misses 339 339 Partials 229 229 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

qweeah commented 3 weeks ago

@TerryHowe What kind of problem is expected to be resolved by this PR? Moving print-related utilities out of status folder is doable, but status package including the handlers should be placed side-by-side with metadata in the same folder level.

Types of output

Taking pull artifact as an example:

$ oras pull --oci-layout hello:latest --no-tty
Downloading a948904f2f0f hello.txt
Downloaded  a948904f2f0f hello.txt
Pulled [oci-layout] hello:latest
Digest: sha256:6ca2cbb8dc842320c8b9ae609dfb2f9a83eb0be382cbc0c75c6bbdd51a15b242

Status output:

Downloading a948904f2f0f hello.txt
Downloaded  a948904f2f0f hello.txt

Metadata output:

Pulled [oci-layout] hello:latest
Digest: sha256:6ca2cbb8dc842320c8b9ae609dfb2f9a83eb0be382cbc0c75c6bbdd51a15b242
TerryHowe commented 3 weeks ago

I just created this PR to give better separation of concerns and avoid possible circular dependencies. The Printer is a like a logging system and really shouldn't be dependent on what it logs.

qweeah commented 3 weeks ago

@TerryHowe Got it, then this PR should only move print.go and print_test.go