From 356b00b652433261c45aaa3c3fb449b94fc52c70 Mon Sep 17 00:00:00 2001 From: Terry Howe Date: Tue, 28 May 2024 16:44:32 -0600 Subject: [PATCH] refactor: Move handlers to handler package Signed-off-by: Terry Howe --- .../display/{status => }/console/console.go | 0 .../{status => }/console/console_test.go | 0 .../console/testutils/testutils.go | 0 .../internal/display/{status => }/print.go | 4 ++-- .../display/{status => }/print_test.go | 2 +- .../{status => }/progress/humanize/bytes.go | 0 .../progress/humanize/bytes_test.go | 0 .../display/{status => }/progress/manager.go | 2 +- .../display/{status => }/progress/speed.go | 0 .../{status => }/progress/speed_test.go | 0 .../display/{status => }/progress/spinner.go | 0 .../{status => }/progress/spinner_test.go | 0 .../display/{status => }/progress/status.go | 2 +- .../{status => }/progress/status_test.go | 6 +++--- .../{display => handler}/content/discard.go | 0 .../{display => handler}/content/interface.go | 0 .../content/manifest_fetch.go | 2 +- .../internal/{display => handler}/handler.go | 20 +++++++++---------- .../metadata/descriptor/manifest_fetch.go | 4 ++-- .../{display => handler}/metadata/discard.go | 0 .../metadata/interface.go | 0 .../metadata/json/attach.go | 6 +++--- .../metadata/json/discover.go | 6 +++--- .../metadata/json/manifest_fetch.go | 6 +++--- .../metadata/json/pull.go | 6 +++--- .../metadata/json/push.go | 6 +++--- .../metadata/model/attach.go | 0 .../metadata/model/descriptor.go | 0 .../metadata/model/discover.go | 0 .../metadata/model/fetched.go | 0 .../metadata/model/pull.go | 0 .../metadata/model/push.go | 0 .../metadata/model/tag.go | 0 .../metadata/table/discover.go | 4 ++-- .../metadata/template/attach.go | 4 ++-- .../metadata/template/discover.go | 4 ++-- .../metadata/template/manifest_fetch.go | 4 ++-- .../metadata/template/pull.go | 4 ++-- .../metadata/template/push.go | 4 ++-- .../metadata/template/template.go | 2 +- .../metadata/template/template_test.go | 0 .../metadata/text/attach.go | 2 +- .../metadata/text/pull.go | 2 +- .../metadata/text/push.go | 2 +- .../metadata/text/push_test.go | 0 .../metadata/tree/discover.go | 2 +- .../{display => handler}/status/deprecated.go | 5 +++-- .../{display => handler}/status/discard.go | 0 .../{display => handler}/status/interface.go | 0 .../{display => handler}/status/text.go | 11 +++++----- .../status/track/reader.go | 2 +- .../status/track/target.go | 2 +- .../status/track/target_test.go | 2 +- .../{display => handler}/status/tty.go | 5 +++-- .../{display => handler}/status/tty_test.go | 4 ++-- .../{display => handler}/status/utils.go | 0 .../{display => handler}/utils/const.go | 0 .../{display => handler}/utils/json.go | 0 cmd/oras/internal/option/common_unix_test.go | 2 +- cmd/oras/internal/option/pretty.go | 2 +- cmd/oras/root/attach.go | 4 ++-- cmd/oras/root/blob/fetch.go | 2 +- cmd/oras/root/blob/fetch_test.go | 2 +- cmd/oras/root/blob/push.go | 8 ++++---- cmd/oras/root/blob/push_test.go | 6 +++--- cmd/oras/root/cp.go | 13 ++++++------ cmd/oras/root/cp_test.go | 10 +++++----- cmd/oras/root/discover.go | 8 ++++---- cmd/oras/root/file.go | 2 +- cmd/oras/root/manifest/fetch.go | 4 ++-- cmd/oras/root/manifest/push.go | 5 +++-- cmd/oras/root/pull.go | 8 ++++---- cmd/oras/root/pull_test.go | 2 +- cmd/oras/root/push.go | 6 +++--- cmd/oras/root/tag.go | 2 +- test/e2e/suite/command/discover.go | 2 +- 76 files changed, 115 insertions(+), 110 deletions(-) rename cmd/oras/internal/display/{status => }/console/console.go (100%) rename cmd/oras/internal/display/{status => }/console/console_test.go (100%) rename cmd/oras/internal/display/{status => }/console/testutils/testutils.go (100%) rename cmd/oras/internal/display/{status => }/print.go (97%) rename cmd/oras/internal/display/{status => }/print_test.go (99%) rename cmd/oras/internal/display/{status => }/progress/humanize/bytes.go (100%) rename cmd/oras/internal/display/{status => }/progress/humanize/bytes_test.go (100%) rename cmd/oras/internal/display/{status => }/progress/manager.go (98%) rename cmd/oras/internal/display/{status => }/progress/speed.go (100%) rename cmd/oras/internal/display/{status => }/progress/speed_test.go (100%) rename cmd/oras/internal/display/{status => }/progress/spinner.go (100%) rename cmd/oras/internal/display/{status => }/progress/spinner_test.go (100%) rename cmd/oras/internal/display/{status => }/progress/status.go (98%) rename cmd/oras/internal/display/{status => }/progress/status_test.go (96%) rename cmd/oras/internal/{display => handler}/content/discard.go (100%) rename cmd/oras/internal/{display => handler}/content/interface.go (100%) rename cmd/oras/internal/{display => handler}/content/manifest_fetch.go (96%) rename cmd/oras/internal/{display => handler}/handler.go (91%) rename cmd/oras/internal/{display => handler}/metadata/descriptor/manifest_fetch.go (92%) rename cmd/oras/internal/{display => handler}/metadata/discard.go (100%) rename cmd/oras/internal/{display => handler}/metadata/interface.go (100%) rename cmd/oras/internal/{display => handler}/metadata/json/attach.go (88%) rename cmd/oras/internal/{display => handler}/metadata/json/discover.go (91%) rename cmd/oras/internal/{display => handler}/metadata/json/manifest_fetch.go (89%) rename cmd/oras/internal/{display => handler}/metadata/json/pull.go (90%) rename cmd/oras/internal/{display => handler}/metadata/json/push.go (91%) rename cmd/oras/internal/{display => handler}/metadata/model/attach.go (100%) rename cmd/oras/internal/{display => handler}/metadata/model/descriptor.go (100%) rename cmd/oras/internal/{display => handler}/metadata/model/discover.go (100%) rename cmd/oras/internal/{display => handler}/metadata/model/fetched.go (100%) rename cmd/oras/internal/{display => handler}/metadata/model/pull.go (100%) rename cmd/oras/internal/{display => handler}/metadata/model/push.go (100%) rename cmd/oras/internal/{display => handler}/metadata/model/tag.go (100%) rename cmd/oras/internal/{display => handler}/metadata/table/discover.go (96%) rename cmd/oras/internal/{display => handler}/metadata/template/attach.go (91%) rename cmd/oras/internal/{display => handler}/metadata/template/discover.go (94%) rename cmd/oras/internal/{display => handler}/metadata/template/manifest_fetch.go (92%) rename cmd/oras/internal/{display => handler}/metadata/template/pull.go (93%) rename cmd/oras/internal/{display => handler}/metadata/template/push.go (93%) rename cmd/oras/internal/{display => handler}/metadata/template/template.go (95%) rename cmd/oras/internal/{display => handler}/metadata/template/template_test.go (100%) rename cmd/oras/internal/{display => handler}/metadata/text/attach.go (96%) rename cmd/oras/internal/{display => handler}/metadata/text/pull.go (97%) rename cmd/oras/internal/{display => handler}/metadata/text/push.go (96%) rename cmd/oras/internal/{display => handler}/metadata/text/push_test.go (100%) rename cmd/oras/internal/{display => handler}/metadata/tree/discover.go (97%) rename cmd/oras/internal/{display => handler}/status/deprecated.go (93%) rename cmd/oras/internal/{display => handler}/status/discard.go (100%) rename cmd/oras/internal/{display => handler}/status/interface.go (100%) rename cmd/oras/internal/{display => handler}/status/text.go (93%) rename cmd/oras/internal/{display => handler}/status/track/reader.go (97%) rename cmd/oras/internal/{display => handler}/status/track/target.go (98%) rename cmd/oras/internal/{display => handler}/status/track/target_test.go (97%) rename cmd/oras/internal/{display => handler}/status/tty.go (95%) rename cmd/oras/internal/{display => handler}/status/tty_test.go (97%) rename cmd/oras/internal/{display => handler}/status/utils.go (100%) rename cmd/oras/internal/{display => handler}/utils/const.go (100%) rename cmd/oras/internal/{display => handler}/utils/json.go (100%) diff --git a/cmd/oras/internal/display/status/console/console.go b/cmd/oras/internal/display/console/console.go similarity index 100% rename from cmd/oras/internal/display/status/console/console.go rename to cmd/oras/internal/display/console/console.go diff --git a/cmd/oras/internal/display/status/console/console_test.go b/cmd/oras/internal/display/console/console_test.go similarity index 100% rename from cmd/oras/internal/display/status/console/console_test.go rename to cmd/oras/internal/display/console/console_test.go diff --git a/cmd/oras/internal/display/status/console/testutils/testutils.go b/cmd/oras/internal/display/console/testutils/testutils.go similarity index 100% rename from cmd/oras/internal/display/status/console/testutils/testutils.go rename to cmd/oras/internal/display/console/testutils/testutils.go diff --git a/cmd/oras/internal/display/status/print.go b/cmd/oras/internal/display/print.go similarity index 97% rename from cmd/oras/internal/display/status/print.go rename to cmd/oras/internal/display/print.go index 1d0c102bd..abe171e7e 100644 --- a/cmd/oras/internal/display/status/print.go +++ b/cmd/oras/internal/display/print.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package status +package display import ( "context" @@ -47,7 +47,7 @@ func (p *Printer) Println(a ...any) error { defer p.lock.Unlock() _, err := fmt.Fprintln(p.out, a...) if err != nil { - err = fmt.Errorf("display output error: %w", err) + err = fmt.Errorf("handler output error: %w", err) _, _ = fmt.Fprint(os.Stderr, err) } // Errors are handled above, so return nil diff --git a/cmd/oras/internal/display/status/print_test.go b/cmd/oras/internal/display/print_test.go similarity index 99% rename from cmd/oras/internal/display/status/print_test.go rename to cmd/oras/internal/display/print_test.go index 4867ec17b..20fa966e1 100644 --- a/cmd/oras/internal/display/status/print_test.go +++ b/cmd/oras/internal/display/print_test.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package status +package display import ( "fmt" diff --git a/cmd/oras/internal/display/status/progress/humanize/bytes.go b/cmd/oras/internal/display/progress/humanize/bytes.go similarity index 100% rename from cmd/oras/internal/display/status/progress/humanize/bytes.go rename to cmd/oras/internal/display/progress/humanize/bytes.go diff --git a/cmd/oras/internal/display/status/progress/humanize/bytes_test.go b/cmd/oras/internal/display/progress/humanize/bytes_test.go similarity index 100% rename from cmd/oras/internal/display/status/progress/humanize/bytes_test.go rename to cmd/oras/internal/display/progress/humanize/bytes_test.go diff --git a/cmd/oras/internal/display/status/progress/manager.go b/cmd/oras/internal/display/progress/manager.go similarity index 98% rename from cmd/oras/internal/display/status/progress/manager.go rename to cmd/oras/internal/display/progress/manager.go index b17d61e00..0d785508d 100644 --- a/cmd/oras/internal/display/status/progress/manager.go +++ b/cmd/oras/internal/display/progress/manager.go @@ -21,7 +21,7 @@ import ( "sync" "time" - "oras.land/oras/cmd/oras/internal/display/status/console" + "oras.land/oras/cmd/oras/internal/display/console" ) const ( diff --git a/cmd/oras/internal/display/status/progress/speed.go b/cmd/oras/internal/display/progress/speed.go similarity index 100% rename from cmd/oras/internal/display/status/progress/speed.go rename to cmd/oras/internal/display/progress/speed.go diff --git a/cmd/oras/internal/display/status/progress/speed_test.go b/cmd/oras/internal/display/progress/speed_test.go similarity index 100% rename from cmd/oras/internal/display/status/progress/speed_test.go rename to cmd/oras/internal/display/progress/speed_test.go diff --git a/cmd/oras/internal/display/status/progress/spinner.go b/cmd/oras/internal/display/progress/spinner.go similarity index 100% rename from cmd/oras/internal/display/status/progress/spinner.go rename to cmd/oras/internal/display/progress/spinner.go diff --git a/cmd/oras/internal/display/status/progress/spinner_test.go b/cmd/oras/internal/display/progress/spinner_test.go similarity index 100% rename from cmd/oras/internal/display/status/progress/spinner_test.go rename to cmd/oras/internal/display/progress/spinner_test.go diff --git a/cmd/oras/internal/display/status/progress/status.go b/cmd/oras/internal/display/progress/status.go similarity index 98% rename from cmd/oras/internal/display/status/progress/status.go rename to cmd/oras/internal/display/progress/status.go index b2abb6ee4..4951cd403 100644 --- a/cmd/oras/internal/display/status/progress/status.go +++ b/cmd/oras/internal/display/progress/status.go @@ -24,7 +24,7 @@ import ( "github.com/morikuni/aec" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/status/progress/humanize" + "oras.land/oras/cmd/oras/internal/display/progress/humanize" ) const ( diff --git a/cmd/oras/internal/display/status/progress/status_test.go b/cmd/oras/internal/display/progress/status_test.go similarity index 96% rename from cmd/oras/internal/display/status/progress/status_test.go rename to cmd/oras/internal/display/progress/status_test.go index 417ffb45e..2ba65ba87 100644 --- a/cmd/oras/internal/display/status/progress/status_test.go +++ b/cmd/oras/internal/display/progress/status_test.go @@ -22,9 +22,9 @@ import ( "time" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/status/console" - "oras.land/oras/cmd/oras/internal/display/status/console/testutils" - "oras.land/oras/cmd/oras/internal/display/status/progress/humanize" + "oras.land/oras/cmd/oras/internal/display/console" + "oras.land/oras/cmd/oras/internal/display/console/testutils" + "oras.land/oras/cmd/oras/internal/display/progress/humanize" ) func Test_status_String(t *testing.T) { diff --git a/cmd/oras/internal/display/content/discard.go b/cmd/oras/internal/handler/content/discard.go similarity index 100% rename from cmd/oras/internal/display/content/discard.go rename to cmd/oras/internal/handler/content/discard.go diff --git a/cmd/oras/internal/display/content/interface.go b/cmd/oras/internal/handler/content/interface.go similarity index 100% rename from cmd/oras/internal/display/content/interface.go rename to cmd/oras/internal/handler/content/interface.go diff --git a/cmd/oras/internal/display/content/manifest_fetch.go b/cmd/oras/internal/handler/content/manifest_fetch.go similarity index 96% rename from cmd/oras/internal/display/content/manifest_fetch.go rename to cmd/oras/internal/handler/content/manifest_fetch.go index 20707b04b..20a784265 100644 --- a/cmd/oras/internal/display/content/manifest_fetch.go +++ b/cmd/oras/internal/handler/content/manifest_fetch.go @@ -21,7 +21,7 @@ import ( "os" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/utils" + "oras.land/oras/cmd/oras/internal/handler/utils" ) // manifestFetch handles raw content output. diff --git a/cmd/oras/internal/display/handler.go b/cmd/oras/internal/handler/handler.go similarity index 91% rename from cmd/oras/internal/display/handler.go rename to cmd/oras/internal/handler/handler.go index 3b3da398c..0c8ff7e1a 100644 --- a/cmd/oras/internal/display/handler.go +++ b/cmd/oras/internal/handler/handler.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package display +package handler import ( "io" @@ -21,16 +21,16 @@ import ( ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/content" - "oras.land/oras/cmd/oras/internal/display/metadata" - "oras.land/oras/cmd/oras/internal/display/metadata/descriptor" - "oras.land/oras/cmd/oras/internal/display/metadata/json" - "oras.land/oras/cmd/oras/internal/display/metadata/table" - "oras.land/oras/cmd/oras/internal/display/metadata/template" - "oras.land/oras/cmd/oras/internal/display/metadata/text" - "oras.land/oras/cmd/oras/internal/display/metadata/tree" - "oras.land/oras/cmd/oras/internal/display/status" "oras.land/oras/cmd/oras/internal/errors" + "oras.land/oras/cmd/oras/internal/handler/content" + "oras.land/oras/cmd/oras/internal/handler/metadata" + "oras.land/oras/cmd/oras/internal/handler/metadata/descriptor" + "oras.land/oras/cmd/oras/internal/handler/metadata/json" + "oras.land/oras/cmd/oras/internal/handler/metadata/table" + "oras.land/oras/cmd/oras/internal/handler/metadata/template" + "oras.land/oras/cmd/oras/internal/handler/metadata/text" + "oras.land/oras/cmd/oras/internal/handler/metadata/tree" + "oras.land/oras/cmd/oras/internal/handler/status" "oras.land/oras/cmd/oras/internal/option" ) diff --git a/cmd/oras/internal/display/metadata/descriptor/manifest_fetch.go b/cmd/oras/internal/handler/metadata/descriptor/manifest_fetch.go similarity index 92% rename from cmd/oras/internal/display/metadata/descriptor/manifest_fetch.go rename to cmd/oras/internal/handler/metadata/descriptor/manifest_fetch.go index a55407494..03f4c7653 100644 --- a/cmd/oras/internal/display/metadata/descriptor/manifest_fetch.go +++ b/cmd/oras/internal/handler/metadata/descriptor/manifest_fetch.go @@ -21,8 +21,8 @@ import ( "io" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/metadata" - "oras.land/oras/cmd/oras/internal/display/utils" + "oras.land/oras/cmd/oras/internal/handler/metadata" + "oras.land/oras/cmd/oras/internal/handler/utils" ) // manifestFetchHandler handles metadata descriptor output. diff --git a/cmd/oras/internal/display/metadata/discard.go b/cmd/oras/internal/handler/metadata/discard.go similarity index 100% rename from cmd/oras/internal/display/metadata/discard.go rename to cmd/oras/internal/handler/metadata/discard.go diff --git a/cmd/oras/internal/display/metadata/interface.go b/cmd/oras/internal/handler/metadata/interface.go similarity index 100% rename from cmd/oras/internal/display/metadata/interface.go rename to cmd/oras/internal/handler/metadata/interface.go diff --git a/cmd/oras/internal/display/metadata/json/attach.go b/cmd/oras/internal/handler/metadata/json/attach.go similarity index 88% rename from cmd/oras/internal/display/metadata/json/attach.go rename to cmd/oras/internal/handler/metadata/json/attach.go index 3c224a798..14741577e 100644 --- a/cmd/oras/internal/display/metadata/json/attach.go +++ b/cmd/oras/internal/handler/metadata/json/attach.go @@ -19,9 +19,9 @@ import ( "io" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/metadata" - "oras.land/oras/cmd/oras/internal/display/metadata/model" - "oras.land/oras/cmd/oras/internal/display/utils" + "oras.land/oras/cmd/oras/internal/handler/metadata" + "oras.land/oras/cmd/oras/internal/handler/metadata/model" + "oras.land/oras/cmd/oras/internal/handler/utils" "oras.land/oras/cmd/oras/internal/option" ) diff --git a/cmd/oras/internal/display/metadata/json/discover.go b/cmd/oras/internal/handler/metadata/json/discover.go similarity index 91% rename from cmd/oras/internal/display/metadata/json/discover.go rename to cmd/oras/internal/handler/metadata/json/discover.go index f6eabbaad..c4d78d710 100644 --- a/cmd/oras/internal/display/metadata/json/discover.go +++ b/cmd/oras/internal/handler/metadata/json/discover.go @@ -21,9 +21,9 @@ import ( ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2/content" - "oras.land/oras/cmd/oras/internal/display/metadata" - "oras.land/oras/cmd/oras/internal/display/metadata/model" - "oras.land/oras/cmd/oras/internal/display/utils" + "oras.land/oras/cmd/oras/internal/handler/metadata" + "oras.land/oras/cmd/oras/internal/handler/metadata/model" + "oras.land/oras/cmd/oras/internal/handler/utils" ) // discoverHandler handles json metadata output for discover events. diff --git a/cmd/oras/internal/display/metadata/json/manifest_fetch.go b/cmd/oras/internal/handler/metadata/json/manifest_fetch.go similarity index 89% rename from cmd/oras/internal/display/metadata/json/manifest_fetch.go rename to cmd/oras/internal/handler/metadata/json/manifest_fetch.go index 5d1eaa31f..b4422a824 100644 --- a/cmd/oras/internal/display/metadata/json/manifest_fetch.go +++ b/cmd/oras/internal/handler/metadata/json/manifest_fetch.go @@ -20,9 +20,9 @@ import ( "io" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/metadata" - "oras.land/oras/cmd/oras/internal/display/metadata/model" - "oras.land/oras/cmd/oras/internal/display/utils" + "oras.land/oras/cmd/oras/internal/handler/metadata" + "oras.land/oras/cmd/oras/internal/handler/metadata/model" + "oras.land/oras/cmd/oras/internal/handler/utils" ) // manifestFetchHandler handles JSON metadata output for manifest fetch events. diff --git a/cmd/oras/internal/display/metadata/json/pull.go b/cmd/oras/internal/handler/metadata/json/pull.go similarity index 90% rename from cmd/oras/internal/display/metadata/json/pull.go rename to cmd/oras/internal/handler/metadata/json/pull.go index 50bff8bdc..ef27304d2 100644 --- a/cmd/oras/internal/display/metadata/json/pull.go +++ b/cmd/oras/internal/handler/metadata/json/pull.go @@ -19,9 +19,9 @@ import ( "io" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/metadata" - "oras.land/oras/cmd/oras/internal/display/metadata/model" - "oras.land/oras/cmd/oras/internal/display/utils" + "oras.land/oras/cmd/oras/internal/handler/metadata" + "oras.land/oras/cmd/oras/internal/handler/metadata/model" + "oras.land/oras/cmd/oras/internal/handler/utils" "oras.land/oras/cmd/oras/internal/option" ) diff --git a/cmd/oras/internal/display/metadata/json/push.go b/cmd/oras/internal/handler/metadata/json/push.go similarity index 91% rename from cmd/oras/internal/display/metadata/json/push.go rename to cmd/oras/internal/handler/metadata/json/push.go index 9d1863a38..40190af4f 100644 --- a/cmd/oras/internal/display/metadata/json/push.go +++ b/cmd/oras/internal/handler/metadata/json/push.go @@ -19,9 +19,9 @@ import ( "io" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/metadata" - "oras.land/oras/cmd/oras/internal/display/metadata/model" - "oras.land/oras/cmd/oras/internal/display/utils" + "oras.land/oras/cmd/oras/internal/handler/metadata" + "oras.land/oras/cmd/oras/internal/handler/metadata/model" + "oras.land/oras/cmd/oras/internal/handler/utils" "oras.land/oras/cmd/oras/internal/option" "oras.land/oras/internal/contentutil" ) diff --git a/cmd/oras/internal/display/metadata/model/attach.go b/cmd/oras/internal/handler/metadata/model/attach.go similarity index 100% rename from cmd/oras/internal/display/metadata/model/attach.go rename to cmd/oras/internal/handler/metadata/model/attach.go diff --git a/cmd/oras/internal/display/metadata/model/descriptor.go b/cmd/oras/internal/handler/metadata/model/descriptor.go similarity index 100% rename from cmd/oras/internal/display/metadata/model/descriptor.go rename to cmd/oras/internal/handler/metadata/model/descriptor.go diff --git a/cmd/oras/internal/display/metadata/model/discover.go b/cmd/oras/internal/handler/metadata/model/discover.go similarity index 100% rename from cmd/oras/internal/display/metadata/model/discover.go rename to cmd/oras/internal/handler/metadata/model/discover.go diff --git a/cmd/oras/internal/display/metadata/model/fetched.go b/cmd/oras/internal/handler/metadata/model/fetched.go similarity index 100% rename from cmd/oras/internal/display/metadata/model/fetched.go rename to cmd/oras/internal/handler/metadata/model/fetched.go diff --git a/cmd/oras/internal/display/metadata/model/pull.go b/cmd/oras/internal/handler/metadata/model/pull.go similarity index 100% rename from cmd/oras/internal/display/metadata/model/pull.go rename to cmd/oras/internal/handler/metadata/model/pull.go diff --git a/cmd/oras/internal/display/metadata/model/push.go b/cmd/oras/internal/handler/metadata/model/push.go similarity index 100% rename from cmd/oras/internal/display/metadata/model/push.go rename to cmd/oras/internal/handler/metadata/model/push.go diff --git a/cmd/oras/internal/display/metadata/model/tag.go b/cmd/oras/internal/handler/metadata/model/tag.go similarity index 100% rename from cmd/oras/internal/display/metadata/model/tag.go rename to cmd/oras/internal/handler/metadata/model/tag.go diff --git a/cmd/oras/internal/display/metadata/table/discover.go b/cmd/oras/internal/handler/metadata/table/discover.go similarity index 96% rename from cmd/oras/internal/display/metadata/table/discover.go rename to cmd/oras/internal/handler/metadata/table/discover.go index dd930c578..183d7ad7d 100644 --- a/cmd/oras/internal/display/metadata/table/discover.go +++ b/cmd/oras/internal/handler/metadata/table/discover.go @@ -22,8 +22,8 @@ import ( ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2/content" - "oras.land/oras/cmd/oras/internal/display/metadata" - "oras.land/oras/cmd/oras/internal/display/utils" + "oras.land/oras/cmd/oras/internal/handler/metadata" + "oras.land/oras/cmd/oras/internal/handler/utils" ) // discoverHandler handles json metadata output for discover events. diff --git a/cmd/oras/internal/display/metadata/template/attach.go b/cmd/oras/internal/handler/metadata/template/attach.go similarity index 91% rename from cmd/oras/internal/display/metadata/template/attach.go rename to cmd/oras/internal/handler/metadata/template/attach.go index b18b3a285..cceb0c5d5 100644 --- a/cmd/oras/internal/display/metadata/template/attach.go +++ b/cmd/oras/internal/handler/metadata/template/attach.go @@ -19,8 +19,8 @@ import ( "io" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/metadata" - "oras.land/oras/cmd/oras/internal/display/metadata/model" + "oras.land/oras/cmd/oras/internal/handler/metadata" + "oras.land/oras/cmd/oras/internal/handler/metadata/model" "oras.land/oras/cmd/oras/internal/option" ) diff --git a/cmd/oras/internal/display/metadata/template/discover.go b/cmd/oras/internal/handler/metadata/template/discover.go similarity index 94% rename from cmd/oras/internal/display/metadata/template/discover.go rename to cmd/oras/internal/handler/metadata/template/discover.go index 86b50440a..eae8755ff 100644 --- a/cmd/oras/internal/display/metadata/template/discover.go +++ b/cmd/oras/internal/handler/metadata/template/discover.go @@ -21,8 +21,8 @@ import ( ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2/content" - "oras.land/oras/cmd/oras/internal/display/metadata" - "oras.land/oras/cmd/oras/internal/display/metadata/model" + "oras.land/oras/cmd/oras/internal/handler/metadata" + "oras.land/oras/cmd/oras/internal/handler/metadata/model" ) // discoverHandler handles json metadata output for discover events. diff --git a/cmd/oras/internal/display/metadata/template/manifest_fetch.go b/cmd/oras/internal/handler/metadata/template/manifest_fetch.go similarity index 92% rename from cmd/oras/internal/display/metadata/template/manifest_fetch.go rename to cmd/oras/internal/handler/metadata/template/manifest_fetch.go index 8148f13d6..3c5d02586 100644 --- a/cmd/oras/internal/display/metadata/template/manifest_fetch.go +++ b/cmd/oras/internal/handler/metadata/template/manifest_fetch.go @@ -20,8 +20,8 @@ import ( "io" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/metadata" - "oras.land/oras/cmd/oras/internal/display/metadata/model" + "oras.land/oras/cmd/oras/internal/handler/metadata" + "oras.land/oras/cmd/oras/internal/handler/metadata/model" ) // manifestFetchHandler handles JSON metadata output for manifest fetch events. diff --git a/cmd/oras/internal/display/metadata/template/pull.go b/cmd/oras/internal/handler/metadata/template/pull.go similarity index 93% rename from cmd/oras/internal/display/metadata/template/pull.go rename to cmd/oras/internal/handler/metadata/template/pull.go index fa940f25a..cfab22a85 100644 --- a/cmd/oras/internal/display/metadata/template/pull.go +++ b/cmd/oras/internal/handler/metadata/template/pull.go @@ -19,8 +19,8 @@ import ( "io" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/metadata" - "oras.land/oras/cmd/oras/internal/display/metadata/model" + "oras.land/oras/cmd/oras/internal/handler/metadata" + "oras.land/oras/cmd/oras/internal/handler/metadata/model" "oras.land/oras/cmd/oras/internal/option" ) diff --git a/cmd/oras/internal/display/metadata/template/push.go b/cmd/oras/internal/handler/metadata/template/push.go similarity index 93% rename from cmd/oras/internal/display/metadata/template/push.go rename to cmd/oras/internal/handler/metadata/template/push.go index 2829ee274..cddcae513 100644 --- a/cmd/oras/internal/display/metadata/template/push.go +++ b/cmd/oras/internal/handler/metadata/template/push.go @@ -19,8 +19,8 @@ import ( "io" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/metadata" - "oras.land/oras/cmd/oras/internal/display/metadata/model" + "oras.land/oras/cmd/oras/internal/handler/metadata" + "oras.land/oras/cmd/oras/internal/handler/metadata/model" "oras.land/oras/cmd/oras/internal/option" "oras.land/oras/internal/contentutil" ) diff --git a/cmd/oras/internal/display/metadata/template/template.go b/cmd/oras/internal/handler/metadata/template/template.go similarity index 95% rename from cmd/oras/internal/display/metadata/template/template.go rename to cmd/oras/internal/handler/metadata/template/template.go index 11aae1fb3..c97e1e76f 100644 --- a/cmd/oras/internal/display/metadata/template/template.go +++ b/cmd/oras/internal/handler/metadata/template/template.go @@ -20,7 +20,7 @@ import ( "text/template" "github.com/Masterminds/sprig/v3" - "oras.land/oras/cmd/oras/internal/display/utils" + "oras.land/oras/cmd/oras/internal/handler/utils" ) func parseAndWrite(out io.Writer, object any, templateStr string) error { diff --git a/cmd/oras/internal/display/metadata/template/template_test.go b/cmd/oras/internal/handler/metadata/template/template_test.go similarity index 100% rename from cmd/oras/internal/display/metadata/template/template_test.go rename to cmd/oras/internal/handler/metadata/template/template_test.go diff --git a/cmd/oras/internal/display/metadata/text/attach.go b/cmd/oras/internal/handler/metadata/text/attach.go similarity index 96% rename from cmd/oras/internal/display/metadata/text/attach.go rename to cmd/oras/internal/handler/metadata/text/attach.go index d73d32bbb..3bdb536ea 100644 --- a/cmd/oras/internal/display/metadata/text/attach.go +++ b/cmd/oras/internal/handler/metadata/text/attach.go @@ -21,7 +21,7 @@ import ( "strings" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/metadata" + "oras.land/oras/cmd/oras/internal/handler/metadata" "oras.land/oras/cmd/oras/internal/option" ) diff --git a/cmd/oras/internal/display/metadata/text/pull.go b/cmd/oras/internal/handler/metadata/text/pull.go similarity index 97% rename from cmd/oras/internal/display/metadata/text/pull.go rename to cmd/oras/internal/handler/metadata/text/pull.go index 2413b5957..658d548b6 100644 --- a/cmd/oras/internal/display/metadata/text/pull.go +++ b/cmd/oras/internal/handler/metadata/text/pull.go @@ -21,7 +21,7 @@ import ( "sync/atomic" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/metadata" + "oras.land/oras/cmd/oras/internal/handler/metadata" "oras.land/oras/cmd/oras/internal/option" ) diff --git a/cmd/oras/internal/display/metadata/text/push.go b/cmd/oras/internal/handler/metadata/text/push.go similarity index 96% rename from cmd/oras/internal/display/metadata/text/push.go rename to cmd/oras/internal/handler/metadata/text/push.go index d8659b9f0..55477f675 100644 --- a/cmd/oras/internal/display/metadata/text/push.go +++ b/cmd/oras/internal/handler/metadata/text/push.go @@ -21,7 +21,7 @@ import ( "sync" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/metadata" + "oras.land/oras/cmd/oras/internal/handler/metadata" "oras.land/oras/cmd/oras/internal/option" ) diff --git a/cmd/oras/internal/display/metadata/text/push_test.go b/cmd/oras/internal/handler/metadata/text/push_test.go similarity index 100% rename from cmd/oras/internal/display/metadata/text/push_test.go rename to cmd/oras/internal/handler/metadata/text/push_test.go diff --git a/cmd/oras/internal/display/metadata/tree/discover.go b/cmd/oras/internal/handler/metadata/tree/discover.go similarity index 97% rename from cmd/oras/internal/display/metadata/tree/discover.go rename to cmd/oras/internal/handler/metadata/tree/discover.go index 496de1279..a31088bf7 100644 --- a/cmd/oras/internal/display/metadata/tree/discover.go +++ b/cmd/oras/internal/handler/metadata/tree/discover.go @@ -23,7 +23,7 @@ import ( "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "gopkg.in/yaml.v3" - "oras.land/oras/cmd/oras/internal/display/metadata" + "oras.land/oras/cmd/oras/internal/handler/metadata" "oras.land/oras/internal/tree" ) diff --git a/cmd/oras/internal/display/status/deprecated.go b/cmd/oras/internal/handler/status/deprecated.go similarity index 93% rename from cmd/oras/internal/display/status/deprecated.go rename to cmd/oras/internal/handler/status/deprecated.go index 648731b01..f6ac28dc5 100644 --- a/cmd/oras/internal/display/status/deprecated.go +++ b/cmd/oras/internal/handler/status/deprecated.go @@ -16,6 +16,7 @@ limitations under the License. package status import ( + "oras.land/oras/cmd/oras/internal/display" "os" "sync" @@ -54,9 +55,9 @@ func NewTagStatusPrinter(target oras.Target) oras.Target { // printer is used by the code being deprecated. Related functions should be // removed when no-longer referenced. -var printer = NewPrinter(os.Stdout) +var printer = display.NewPrinter(os.Stdout) -// Print objects to display concurrent-safely. +// Print objects to handler concurrent-safely. func Print(a ...any) error { return printer.Println(a...) } diff --git a/cmd/oras/internal/display/status/discard.go b/cmd/oras/internal/handler/status/discard.go similarity index 100% rename from cmd/oras/internal/display/status/discard.go rename to cmd/oras/internal/handler/status/discard.go diff --git a/cmd/oras/internal/display/status/interface.go b/cmd/oras/internal/handler/status/interface.go similarity index 100% rename from cmd/oras/internal/display/status/interface.go rename to cmd/oras/internal/handler/status/interface.go diff --git a/cmd/oras/internal/display/status/text.go b/cmd/oras/internal/handler/status/text.go similarity index 93% rename from cmd/oras/internal/display/status/text.go rename to cmd/oras/internal/handler/status/text.go index 6baf762c2..aa4dafaed 100644 --- a/cmd/oras/internal/display/status/text.go +++ b/cmd/oras/internal/handler/status/text.go @@ -18,6 +18,7 @@ package status import ( "context" "io" + "oras.land/oras/cmd/oras/internal/display" "sync" ocispec "github.com/opencontainers/image-spec/specs-go/v1" @@ -28,14 +29,14 @@ import ( // TextPushHandler handles text status output for push events. type TextPushHandler struct { verbose bool - printer *Printer + printer *display.Printer } // NewTextPushHandler returns a new handler for push command. func NewTextPushHandler(out io.Writer, verbose bool) PushHandler { return &TextPushHandler{ verbose: verbose, - printer: NewPrinter(out), + printer: display.NewPrinter(out), } } @@ -75,7 +76,7 @@ func (ph *TextPushHandler) UpdateCopyOptions(opts *oras.CopyGraphOptions, fetche } opts.PostCopy = func(ctx context.Context, desc ocispec.Descriptor) error { committed.Store(desc.Digest.String(), desc.Annotations[ocispec.AnnotationTitle]) - if err := PrintSuccessorStatus(ctx, desc, fetcher, committed, ph.printer.StatusPrinter(promptSkipped, ph.verbose)); err != nil { + if err := display.PrintSuccessorStatus(ctx, desc, fetcher, committed, ph.printer.StatusPrinter(promptSkipped, ph.verbose)); err != nil { return err } return ph.printer.PrintStatus(desc, promptUploaded, ph.verbose) @@ -90,7 +91,7 @@ func NewTextAttachHandler(out io.Writer, verbose bool) AttachHandler { // TextPullHandler handles text status output for pull events. type TextPullHandler struct { verbose bool - printer *Printer + printer *display.Printer } // TrackTarget implements PullHander. @@ -127,6 +128,6 @@ func (ph *TextPullHandler) OnNodeSkipped(desc ocispec.Descriptor) error { func NewTextPullHandler(out io.Writer, verbose bool) PullHandler { return &TextPullHandler{ verbose: verbose, - printer: NewPrinter(out), + printer: display.NewPrinter(out), } } diff --git a/cmd/oras/internal/display/status/track/reader.go b/cmd/oras/internal/handler/status/track/reader.go similarity index 97% rename from cmd/oras/internal/display/status/track/reader.go rename to cmd/oras/internal/handler/status/track/reader.go index 28f647d36..819ca830f 100644 --- a/cmd/oras/internal/display/status/track/reader.go +++ b/cmd/oras/internal/handler/status/track/reader.go @@ -17,10 +17,10 @@ package track import ( "io" + "oras.land/oras/cmd/oras/internal/display/progress" "os" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras/cmd/oras/internal/display/status/progress" ) type reader struct { diff --git a/cmd/oras/internal/display/status/track/target.go b/cmd/oras/internal/handler/status/track/target.go similarity index 98% rename from cmd/oras/internal/display/status/track/target.go rename to cmd/oras/internal/handler/status/track/target.go index 9bd54d240..77d14e8ae 100644 --- a/cmd/oras/internal/display/status/track/target.go +++ b/cmd/oras/internal/handler/status/track/target.go @@ -18,12 +18,12 @@ package track import ( "context" "io" + "oras.land/oras/cmd/oras/internal/display/progress" "os" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2" "oras.land/oras-go/v2/registry" - "oras.land/oras/cmd/oras/internal/display/status/progress" ) // GraphTarget is a tracked oras.GraphTarget. diff --git a/cmd/oras/internal/display/status/track/target_test.go b/cmd/oras/internal/handler/status/track/target_test.go similarity index 97% rename from cmd/oras/internal/display/status/track/target_test.go rename to cmd/oras/internal/handler/status/track/target_test.go index 3654ba482..76d2f0284 100644 --- a/cmd/oras/internal/display/status/track/target_test.go +++ b/cmd/oras/internal/handler/status/track/target_test.go @@ -28,7 +28,7 @@ import ( "oras.land/oras-go/v2" "oras.land/oras-go/v2/content/memory" "oras.land/oras-go/v2/registry/remote" - "oras.land/oras/cmd/oras/internal/display/status/console/testutils" + "oras.land/oras/cmd/oras/internal/display/console/testutils" ) type testReferenceGraphTarget struct { diff --git a/cmd/oras/internal/display/status/tty.go b/cmd/oras/internal/handler/status/tty.go similarity index 95% rename from cmd/oras/internal/display/status/tty.go rename to cmd/oras/internal/handler/status/tty.go index 19acab537..d720fa969 100644 --- a/cmd/oras/internal/display/status/tty.go +++ b/cmd/oras/internal/handler/status/tty.go @@ -17,13 +17,14 @@ package status import ( "context" + "oras.land/oras/cmd/oras/internal/display" "os" "sync" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2" "oras.land/oras-go/v2/content" - "oras.land/oras/cmd/oras/internal/display/status/track" + "oras.land/oras/cmd/oras/internal/handler/status/track" ) // TTYPushHandler handles TTY status output for push command. @@ -76,7 +77,7 @@ func (ph *TTYPushHandler) UpdateCopyOptions(opts *oras.CopyGraphOptions, fetcher } opts.PostCopy = func(ctx context.Context, desc ocispec.Descriptor) error { committed.Store(desc.Digest.String(), desc.Annotations[ocispec.AnnotationTitle]) - return PrintSuccessorStatus(ctx, desc, fetcher, committed, func(d ocispec.Descriptor) error { + return display.PrintSuccessorStatus(ctx, desc, fetcher, committed, func(d ocispec.Descriptor) error { return ph.tracked.Prompt(d, promptSkipped) }) } diff --git a/cmd/oras/internal/display/status/tty_test.go b/cmd/oras/internal/handler/status/tty_test.go similarity index 97% rename from cmd/oras/internal/display/status/tty_test.go rename to cmd/oras/internal/handler/status/tty_test.go index 119dd9218..13f868c71 100644 --- a/cmd/oras/internal/display/status/tty_test.go +++ b/cmd/oras/internal/handler/status/tty_test.go @@ -28,8 +28,8 @@ import ( ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2" "oras.land/oras-go/v2/content/memory" - "oras.land/oras/cmd/oras/internal/display/status/console/testutils" - "oras.land/oras/cmd/oras/internal/display/status/track" + "oras.land/oras/cmd/oras/internal/display/console/testutils" + "oras.land/oras/cmd/oras/internal/handler/status/track" ) var ( diff --git a/cmd/oras/internal/display/status/utils.go b/cmd/oras/internal/handler/status/utils.go similarity index 100% rename from cmd/oras/internal/display/status/utils.go rename to cmd/oras/internal/handler/status/utils.go diff --git a/cmd/oras/internal/display/utils/const.go b/cmd/oras/internal/handler/utils/const.go similarity index 100% rename from cmd/oras/internal/display/utils/const.go rename to cmd/oras/internal/handler/utils/const.go diff --git a/cmd/oras/internal/display/utils/json.go b/cmd/oras/internal/handler/utils/json.go similarity index 100% rename from cmd/oras/internal/display/utils/json.go rename to cmd/oras/internal/handler/utils/json.go diff --git a/cmd/oras/internal/option/common_unix_test.go b/cmd/oras/internal/option/common_unix_test.go index 82d8f0ed4..58be9b6c9 100644 --- a/cmd/oras/internal/option/common_unix_test.go +++ b/cmd/oras/internal/option/common_unix_test.go @@ -20,7 +20,7 @@ package option import ( "testing" - "oras.land/oras/cmd/oras/internal/display/status/console/testutils" + "oras.land/oras/cmd/oras/internal/display/console/testutils" ) func TestCommon_parseTTY(t *testing.T) { diff --git a/cmd/oras/internal/option/pretty.go b/cmd/oras/internal/option/pretty.go index 6013be141..b3a6d6b68 100644 --- a/cmd/oras/internal/option/pretty.go +++ b/cmd/oras/internal/option/pretty.go @@ -19,7 +19,7 @@ import ( "io" "github.com/spf13/pflag" - "oras.land/oras/cmd/oras/internal/display/utils" + "oras.land/oras/cmd/oras/internal/handler/utils" ) // Pretty option struct. diff --git a/cmd/oras/root/attach.go b/cmd/oras/root/attach.go index ddc77aeba..d40d70232 100644 --- a/cmd/oras/root/attach.go +++ b/cmd/oras/root/attach.go @@ -28,8 +28,8 @@ import ( "oras.land/oras-go/v2/registry/remote/auth" "oras.land/oras/cmd/oras/internal/argument" "oras.land/oras/cmd/oras/internal/command" - "oras.land/oras/cmd/oras/internal/display" oerrors "oras.land/oras/cmd/oras/internal/errors" + "oras.land/oras/cmd/oras/internal/handler" "oras.land/oras/cmd/oras/internal/option" "oras.land/oras/internal/graph" "oras.land/oras/internal/registryutil" @@ -109,7 +109,7 @@ Example - Attach file to the manifest tagged 'v1' in an OCI image layout folder func runAttach(cmd *cobra.Command, opts *attachOptions) error { ctx, logger := command.GetLogger(cmd, &opts.Common) - displayStatus, displayMetadata, err := display.NewAttachHandler(cmd.OutOrStdout(), opts.Format, opts.TTY, opts.Verbose) + displayStatus, displayMetadata, err := handler.NewAttachHandler(cmd.OutOrStdout(), opts.Format, opts.TTY, opts.Verbose) if err != nil { return err } diff --git a/cmd/oras/root/blob/fetch.go b/cmd/oras/root/blob/fetch.go index 44694c428..f7031ffaa 100644 --- a/cmd/oras/root/blob/fetch.go +++ b/cmd/oras/root/blob/fetch.go @@ -28,8 +28,8 @@ import ( "oras.land/oras-go/v2/registry/remote" "oras.land/oras/cmd/oras/internal/argument" "oras.land/oras/cmd/oras/internal/command" - "oras.land/oras/cmd/oras/internal/display/status/track" oerrors "oras.land/oras/cmd/oras/internal/errors" + "oras.land/oras/cmd/oras/internal/handler/status/track" "oras.land/oras/cmd/oras/internal/option" ) diff --git a/cmd/oras/root/blob/fetch_test.go b/cmd/oras/root/blob/fetch_test.go index 3a9e11d1d..c62a157b4 100644 --- a/cmd/oras/root/blob/fetch_test.go +++ b/cmd/oras/root/blob/fetch_test.go @@ -25,7 +25,7 @@ import ( "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2/content/memory" - "oras.land/oras/cmd/oras/internal/display/status/console/testutils" + "oras.land/oras/cmd/oras/internal/display/console/testutils" ) func Test_fetchBlobOptions_doFetch(t *testing.T) { diff --git a/cmd/oras/root/blob/push.go b/cmd/oras/root/blob/push.go index 580b0be4b..9f95c2818 100644 --- a/cmd/oras/root/blob/push.go +++ b/cmd/oras/root/blob/push.go @@ -20,6 +20,7 @@ import ( "errors" "fmt" "io" + "oras.land/oras/cmd/oras/internal/display" "os" ocispec "github.com/opencontainers/image-spec/specs-go/v1" @@ -27,9 +28,8 @@ import ( "oras.land/oras-go/v2" "oras.land/oras/cmd/oras/internal/argument" "oras.land/oras/cmd/oras/internal/command" - "oras.land/oras/cmd/oras/internal/display/status" - "oras.land/oras/cmd/oras/internal/display/status/track" oerrors "oras.land/oras/cmd/oras/internal/errors" + "oras.land/oras/cmd/oras/internal/handler/status/track" "oras.land/oras/cmd/oras/internal/option" "oras.land/oras/internal/file" ) @@ -103,7 +103,7 @@ Example - Push blob 'hi.txt' into an OCI image layout folder 'layout-dir': func pushBlob(cmd *cobra.Command, opts *pushBlobOptions) (err error) { ctx, logger := command.GetLogger(cmd, &opts.Common) - printer := status.NewPrinter(cmd.OutOrStdout()) + printer := display.NewPrinter(cmd.OutOrStdout()) target, err := opts.NewTarget(opts.Common, logger) if err != nil { @@ -145,7 +145,7 @@ func pushBlob(cmd *cobra.Command, opts *pushBlobOptions) (err error) { return nil } -func (opts *pushBlobOptions) doPush(ctx context.Context, printer *status.Printer, t oras.Target, desc ocispec.Descriptor, r io.Reader) error { +func (opts *pushBlobOptions) doPush(ctx context.Context, printer *display.Printer, t oras.Target, desc ocispec.Descriptor, r io.Reader) error { if opts.TTY == nil { // none TTY output if err := printer.PrintStatus(desc, "Uploading", opts.Verbose); err != nil { diff --git a/cmd/oras/root/blob/push_test.go b/cmd/oras/root/blob/push_test.go index b19d1d9ac..20423cd41 100644 --- a/cmd/oras/root/blob/push_test.go +++ b/cmd/oras/root/blob/push_test.go @@ -20,14 +20,14 @@ package blob import ( "bytes" "context" - "oras.land/oras/cmd/oras/internal/display/status" + "oras.land/oras/cmd/oras/internal/display" "os" "testing" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2/content/memory" - "oras.land/oras/cmd/oras/internal/display/status/console/testutils" + "oras.land/oras/cmd/oras/internal/display/console/testutils" ) func Test_pushBlobOptions_doPush(t *testing.T) { @@ -40,7 +40,7 @@ func Test_pushBlobOptions_doPush(t *testing.T) { src := memory.New() content := []byte("test") r := bytes.NewReader(content) - printer := status.NewPrinter(os.Stdout) + printer := display.NewPrinter(os.Stdout) desc := ocispec.Descriptor{ MediaType: "application/octet-stream", Digest: digest.FromBytes(content), diff --git a/cmd/oras/root/cp.go b/cmd/oras/root/cp.go index 7cec065a4..f5b75684d 100644 --- a/cmd/oras/root/cp.go +++ b/cmd/oras/root/cp.go @@ -19,6 +19,7 @@ import ( "context" "encoding/json" "fmt" + "oras.land/oras/cmd/oras/internal/display" "slices" "strings" "sync" @@ -33,9 +34,9 @@ import ( "oras.land/oras-go/v2/registry/remote/auth" "oras.land/oras/cmd/oras/internal/argument" "oras.land/oras/cmd/oras/internal/command" - "oras.land/oras/cmd/oras/internal/display/status" - "oras.land/oras/cmd/oras/internal/display/status/track" oerrors "oras.land/oras/cmd/oras/internal/errors" + "oras.land/oras/cmd/oras/internal/handler/status" + "oras.land/oras/cmd/oras/internal/handler/status/track" "oras.land/oras/cmd/oras/internal/option" "oras.land/oras/internal/docker" "oras.land/oras/internal/graph" @@ -109,7 +110,7 @@ Example - Copy an artifact with multiple tags with concurrency tuned: func runCopy(cmd *cobra.Command, opts *copyOptions) error { ctx, logger := command.GetLogger(cmd, &opts.Common) - printer := status.NewPrinter(cmd.OutOrStdout()) + printer := display.NewPrinter(cmd.OutOrStdout()) // Prepare source src, err := opts.From.NewReadonlyTarget(ctx, opts.Common, logger) @@ -152,7 +153,7 @@ func runCopy(cmd *cobra.Command, opts *copyOptions) error { return nil } -func doCopy(ctx context.Context, printer *status.Printer, src oras.ReadOnlyGraphTarget, dst oras.GraphTarget, opts *copyOptions) (ocispec.Descriptor, error) { +func doCopy(ctx context.Context, printer *display.Printer, src oras.ReadOnlyGraphTarget, dst oras.GraphTarget, opts *copyOptions) (ocispec.Descriptor, error) { // Prepare copy options committed := &sync.Map{} extendedCopyOptions := oras.DefaultExtendedCopyOptions @@ -186,7 +187,7 @@ func doCopy(ctx context.Context, printer *status.Printer, src oras.ReadOnlyGraph } extendedCopyOptions.PostCopy = func(ctx context.Context, desc ocispec.Descriptor) error { committed.Store(desc.Digest.String(), desc.Annotations[ocispec.AnnotationTitle]) - if err := status.PrintSuccessorStatus(ctx, desc, dst, committed, printer.StatusPrinter(promptSkipped, opts.Verbose)); err != nil { + if err := display.PrintSuccessorStatus(ctx, desc, dst, committed, printer.StatusPrinter(promptSkipped, opts.Verbose)); err != nil { return err } return printer.PrintStatus(desc, promptCopied, opts.Verbose) @@ -209,7 +210,7 @@ func doCopy(ctx context.Context, printer *status.Printer, src oras.ReadOnlyGraph } extendedCopyOptions.PostCopy = func(ctx context.Context, desc ocispec.Descriptor) error { committed.Store(desc.Digest.String(), desc.Annotations[ocispec.AnnotationTitle]) - return status.PrintSuccessorStatus(ctx, desc, tracked, committed, func(desc ocispec.Descriptor) error { + return display.PrintSuccessorStatus(ctx, desc, tracked, committed, func(desc ocispec.Descriptor) error { return tracked.Prompt(desc, promptSkipped) }) } diff --git a/cmd/oras/root/cp_test.go b/cmd/oras/root/cp_test.go index 83144a49f..5b6698b92 100644 --- a/cmd/oras/root/cp_test.go +++ b/cmd/oras/root/cp_test.go @@ -24,7 +24,7 @@ import ( "net/http" "net/http/httptest" "net/url" - "oras.land/oras/cmd/oras/internal/display/status" + "oras.land/oras/cmd/oras/internal/display" "os" "strings" "testing" @@ -33,7 +33,7 @@ import ( ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2/content/memory" "oras.land/oras-go/v2/registry/remote" - "oras.land/oras/cmd/oras/internal/display/status/console/testutils" + "oras.land/oras/cmd/oras/internal/display/console/testutils" ) var ( @@ -132,7 +132,7 @@ func Test_doCopy(t *testing.T) { opts.From.Reference = memDesc.Digest.String() dst := memory.New() builder := &strings.Builder{} - printer := status.NewPrinter(builder) + printer := display.NewPrinter(builder) // test _, err = doCopy(context.Background(), printer, memStore, dst, &opts) if err != nil { @@ -156,7 +156,7 @@ func Test_doCopy_skipped(t *testing.T) { opts.Verbose = true opts.From.Reference = memDesc.Digest.String() builder := &strings.Builder{} - printer := status.NewPrinter(builder) + printer := display.NewPrinter(builder) // test _, err = doCopy(context.Background(), printer, memStore, memStore, &opts) if err != nil { @@ -191,7 +191,7 @@ func Test_doCopy_mounted(t *testing.T) { } to.PlainHTTP = true builder := &strings.Builder{} - printer := status.NewPrinter(builder) + printer := display.NewPrinter(builder) // test _, err = doCopy(context.Background(), printer, from, to, &opts) if err != nil { diff --git a/cmd/oras/root/discover.go b/cmd/oras/root/discover.go index 5cde8cfa4..c079af910 100644 --- a/cmd/oras/root/discover.go +++ b/cmd/oras/root/discover.go @@ -27,9 +27,9 @@ import ( "oras.land/oras-go/v2/registry" "oras.land/oras/cmd/oras/internal/argument" "oras.land/oras/cmd/oras/internal/command" - "oras.land/oras/cmd/oras/internal/display" - "oras.land/oras/cmd/oras/internal/display/metadata" oerrors "oras.land/oras/cmd/oras/internal/errors" + "oras.land/oras/cmd/oras/internal/handler" + "oras.land/oras/cmd/oras/internal/handler/metadata" "oras.land/oras/cmd/oras/internal/option" ) @@ -98,7 +98,7 @@ Example - Discover referrers of the manifest tagged 'v1' in an OCI image layout } cmd.Flags().StringVarP(&opts.artifactType, "artifact-type", "", "", "artifact type") - cmd.Flags().StringVarP(&opts.Format.FormatFlag, "output", "o", "tree", "[Deprecated] format in which to display referrers (table, json, or tree). tree format will also show indirect referrers") + cmd.Flags().StringVarP(&opts.Format.FormatFlag, "output", "o", "tree", "[Deprecated] format in which to handler referrers (table, json, or tree). tree format will also show indirect referrers") opts.FormatFlag = option.FormatTypeTree.Name opts.AllowedTypes = []*option.FormatType{ option.FormatTypeTree, @@ -129,7 +129,7 @@ func runDiscover(cmd *cobra.Command, opts *discoverOptions) error { return err } - handler, err := display.NewDiscoverHandler(cmd.OutOrStdout(), opts.Format, opts.Path, opts.RawReference, desc, opts.Verbose) + handler, err := handler.NewDiscoverHandler(cmd.OutOrStdout(), opts.Format, opts.Path, opts.RawReference, desc, opts.Verbose) if err != nil { return err } diff --git a/cmd/oras/root/file.go b/cmd/oras/root/file.go index 1dc9f47a2..38491c84a 100644 --- a/cmd/oras/root/file.go +++ b/cmd/oras/root/file.go @@ -23,8 +23,8 @@ import ( ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2/content/file" - "oras.land/oras/cmd/oras/internal/display/status" "oras.land/oras/cmd/oras/internal/fileref" + "oras.land/oras/cmd/oras/internal/handler/status" ) func loadFiles(ctx context.Context, store *file.Store, annotations map[string]map[string]string, fileRefs []string, displayStatus status.PushHandler) ([]ocispec.Descriptor, error) { diff --git a/cmd/oras/root/manifest/fetch.go b/cmd/oras/root/manifest/fetch.go index c38afe413..eab8aa98d 100644 --- a/cmd/oras/root/manifest/fetch.go +++ b/cmd/oras/root/manifest/fetch.go @@ -24,8 +24,8 @@ import ( "oras.land/oras-go/v2/registry/remote" "oras.land/oras/cmd/oras/internal/argument" "oras.land/oras/cmd/oras/internal/command" - "oras.land/oras/cmd/oras/internal/display" oerrors "oras.land/oras/cmd/oras/internal/errors" + "oras.land/oras/cmd/oras/internal/handler" "oras.land/oras/cmd/oras/internal/option" ) @@ -108,7 +108,7 @@ Example - Fetch raw manifest from an OCI layout archive file 'layout.tar': func fetchManifest(cmd *cobra.Command, opts *fetchOptions) (fetchErr error) { ctx, logger := command.GetLogger(cmd, &opts.Common) - metadataHandler, contentHandler, err := display.NewManifestFetchHandler(cmd.OutOrStdout(), opts.Format, opts.OutputDescriptor, opts.Pretty.Pretty, opts.outputPath) + metadataHandler, contentHandler, err := handler.NewManifestFetchHandler(cmd.OutOrStdout(), opts.Format, opts.OutputDescriptor, opts.Pretty.Pretty, opts.outputPath) if err != nil { return err } diff --git a/cmd/oras/root/manifest/push.go b/cmd/oras/root/manifest/push.go index e09cecbd2..ce9ab4642 100644 --- a/cmd/oras/root/manifest/push.go +++ b/cmd/oras/root/manifest/push.go @@ -19,6 +19,7 @@ import ( "context" "errors" "fmt" + "oras.land/oras/cmd/oras/internal/display" "os" "strings" @@ -30,8 +31,8 @@ import ( "oras.land/oras-go/v2/registry/remote" "oras.land/oras/cmd/oras/internal/argument" "oras.land/oras/cmd/oras/internal/command" - "oras.land/oras/cmd/oras/internal/display/status" oerrors "oras.land/oras/cmd/oras/internal/errors" + "oras.land/oras/cmd/oras/internal/handler/status" "oras.land/oras/cmd/oras/internal/manifest" "oras.land/oras/cmd/oras/internal/option" "oras.land/oras/internal/file" @@ -111,7 +112,7 @@ Example - Push a manifest to an OCI image layout folder 'layout-dir' and tag wit func pushManifest(cmd *cobra.Command, opts pushOptions) error { ctx, logger := command.GetLogger(cmd, &opts.Common) - printer := status.NewPrinter(cmd.OutOrStdout()) + printer := display.NewPrinter(cmd.OutOrStdout()) var target oras.Target var err error target, err = opts.NewTarget(opts.Common, logger) diff --git a/cmd/oras/root/pull.go b/cmd/oras/root/pull.go index 061cd1b79..854dea08b 100644 --- a/cmd/oras/root/pull.go +++ b/cmd/oras/root/pull.go @@ -29,11 +29,11 @@ import ( "oras.land/oras-go/v2/content/file" "oras.land/oras/cmd/oras/internal/argument" "oras.land/oras/cmd/oras/internal/command" - "oras.land/oras/cmd/oras/internal/display" - "oras.land/oras/cmd/oras/internal/display/metadata" - "oras.land/oras/cmd/oras/internal/display/status" oerrors "oras.land/oras/cmd/oras/internal/errors" "oras.land/oras/cmd/oras/internal/fileref" + "oras.land/oras/cmd/oras/internal/handler" + "oras.land/oras/cmd/oras/internal/handler/metadata" + "oras.land/oras/cmd/oras/internal/handler/status" "oras.land/oras/cmd/oras/internal/option" "oras.land/oras/internal/graph" ) @@ -111,7 +111,7 @@ Example - Pull artifact files from an OCI layout archive 'layout.tar': func runPull(cmd *cobra.Command, opts *pullOptions) error { ctx, logger := command.GetLogger(cmd, &opts.Common) - statusHandler, metadataHandler, err := display.NewPullHandler(cmd.OutOrStdout(), opts.Format, opts.Path, opts.TTY, opts.Verbose) + statusHandler, metadataHandler, err := handler.NewPullHandler(cmd.OutOrStdout(), opts.Format, opts.Path, opts.TTY, opts.Verbose) if err != nil { return err } diff --git a/cmd/oras/root/pull_test.go b/cmd/oras/root/pull_test.go index 8e710c1fc..bdf7279f0 100644 --- a/cmd/oras/root/pull_test.go +++ b/cmd/oras/root/pull_test.go @@ -25,7 +25,7 @@ import ( ) func Test_runPull_errType(t *testing.T) { - // prpare + // prepare cmd := &cobra.Command{} cmd.SetContext(context.Background()) diff --git a/cmd/oras/root/push.go b/cmd/oras/root/push.go index ad6145373..833d70069 100644 --- a/cmd/oras/root/push.go +++ b/cmd/oras/root/push.go @@ -28,10 +28,10 @@ import ( "oras.land/oras-go/v2/registry/remote/auth" "oras.land/oras/cmd/oras/internal/argument" "oras.land/oras/cmd/oras/internal/command" - "oras.land/oras/cmd/oras/internal/display" - "oras.land/oras/cmd/oras/internal/display/status" oerrors "oras.land/oras/cmd/oras/internal/errors" "oras.land/oras/cmd/oras/internal/fileref" + "oras.land/oras/cmd/oras/internal/handler" + "oras.land/oras/cmd/oras/internal/handler/status" "oras.land/oras/cmd/oras/internal/option" "oras.land/oras/internal/contentutil" "oras.land/oras/internal/listener" @@ -151,7 +151,7 @@ Example - Push file "hi.txt" into an OCI image layout folder 'layout-dir' with t func runPush(cmd *cobra.Command, opts *pushOptions) error { ctx, logger := command.GetLogger(cmd, &opts.Common) - displayStatus, displayMetadata, err := display.NewPushHandler(cmd.OutOrStdout(), opts.Format, opts.TTY, opts.Verbose) + displayStatus, displayMetadata, err := handler.NewPushHandler(cmd.OutOrStdout(), opts.Format, opts.TTY, opts.Verbose) if err != nil { return err } diff --git a/cmd/oras/root/tag.go b/cmd/oras/root/tag.go index 4eec4c0bd..153d9a80e 100644 --- a/cmd/oras/root/tag.go +++ b/cmd/oras/root/tag.go @@ -24,8 +24,8 @@ import ( "oras.land/oras-go/v2/errdef" "oras.land/oras/cmd/oras/internal/argument" "oras.land/oras/cmd/oras/internal/command" - "oras.land/oras/cmd/oras/internal/display/status" oerrors "oras.land/oras/cmd/oras/internal/errors" + "oras.land/oras/cmd/oras/internal/handler/status" "oras.land/oras/cmd/oras/internal/option" ) diff --git a/test/e2e/suite/command/discover.go b/test/e2e/suite/command/discover.go index 8cdcf5ff1..65c4a8280 100644 --- a/test/e2e/suite/command/discover.go +++ b/test/e2e/suite/command/discover.go @@ -180,7 +180,7 @@ var _ = Describe("1.1 registry users:", func() { Exec() }) - It("should display if a referrer has an empty artifact type", func() { + It("should handler if a referrer has an empty artifact type", func() { ORAS("discover", RegistryRef(ZOTHost, ArtifactRepo, "multi"), "--format", format). MatchKeyWords(""). Exec()