From f64964319489e88e4842d20b28428d1ffd065206 Mon Sep 17 00:00:00 2001 From: Terry Howe Date: Tue, 2 Jul 2024 18:36:57 -0600 Subject: [PATCH] chore: Remove last deprecated method (#1438) Signed-off-by: Terry Howe --- .../internal/display/status/deprecated.go | 33 ------------------- cmd/oras/root/cp.go | 7 ++-- cmd/oras/root/manifest/push.go | 7 ++-- test/e2e/suite/command/manifest.go | 13 ++++++++ 4 files changed, 23 insertions(+), 37 deletions(-) delete mode 100644 cmd/oras/internal/display/status/deprecated.go diff --git a/cmd/oras/internal/display/status/deprecated.go b/cmd/oras/internal/display/status/deprecated.go deleted file mode 100644 index 2d85e3198..000000000 --- a/cmd/oras/internal/display/status/deprecated.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright The ORAS Authors. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package status - -import ( - ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "oras.land/oras-go/v2" - "oras.land/oras/cmd/oras/internal/output" - "oras.land/oras/internal/listener" -) - -// Types and functions in this file are deprecated and should be removed when -// no-longer referenced. - -// NewTagStatusPrinter creates a wrapper type for printing tag status. -func NewTagStatusPrinter(printer *output.Printer, target oras.Target) oras.Target { - return listener.NewTagListener(target, nil, func(desc ocispec.Descriptor, tag string) error { - return printer.Println("Tagged", tag) - }) -} diff --git a/cmd/oras/root/cp.go b/cmd/oras/root/cp.go index 9a2cbbcb6..963bb901d 100644 --- a/cmd/oras/root/cp.go +++ b/cmd/oras/root/cp.go @@ -33,13 +33,14 @@ 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/metadata/text" "oras.land/oras/cmd/oras/internal/display/status/track" oerrors "oras.land/oras/cmd/oras/internal/errors" "oras.land/oras/cmd/oras/internal/option" "oras.land/oras/cmd/oras/internal/output" "oras.land/oras/internal/docker" "oras.land/oras/internal/graph" + "oras.land/oras/internal/listener" "oras.land/oras/internal/registryutil" ) @@ -141,7 +142,9 @@ func runCopy(cmd *cobra.Command, opts *copyOptions) error { if len(opts.extraRefs) != 0 { tagNOpts := oras.DefaultTagNOptions tagNOpts.Concurrency = opts.concurrency - if _, err = oras.TagN(ctx, status.NewTagStatusPrinter(opts.Printer, dst), opts.To.Reference, opts.extraRefs, tagNOpts); err != nil { + tagHandler := text.NewTagHandler(opts.Printer, "") + tagListener := listener.NewTagListener(dst, nil, tagHandler.OnTagged) + if _, err = oras.TagN(ctx, tagListener, opts.To.Reference, opts.extraRefs, tagNOpts); err != nil { return err } } diff --git a/cmd/oras/root/manifest/push.go b/cmd/oras/root/manifest/push.go index 2c11a2dad..93e3ae8f6 100644 --- a/cmd/oras/root/manifest/push.go +++ b/cmd/oras/root/manifest/push.go @@ -30,11 +30,12 @@ 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" + "oras.land/oras/cmd/oras/internal/display/metadata/text" oerrors "oras.land/oras/cmd/oras/internal/errors" "oras.land/oras/cmd/oras/internal/manifest" "oras.land/oras/cmd/oras/internal/option" "oras.land/oras/internal/file" + "oras.land/oras/internal/listener" ) type pushOptions struct { @@ -189,7 +190,9 @@ func pushManifest(cmd *cobra.Command, opts pushOptions) error { } _ = opts.Println("Pushed", opts.AnnotatedReference()) if len(opts.extraRefs) != 0 { - if _, err = oras.TagBytesN(ctx, status.NewTagStatusPrinter(opts.Printer, target), mediaType, contentBytes, opts.extraRefs, tagBytesNOpts); err != nil { + tagHandler := text.NewTagHandler(opts.Printer, "") + tagListener := listener.NewTagListener(target, nil, tagHandler.OnTagged) + if _, err = oras.TagBytesN(ctx, tagListener, mediaType, contentBytes, opts.extraRefs, tagBytesNOpts); err != nil { return err } } diff --git a/test/e2e/suite/command/manifest.go b/test/e2e/suite/command/manifest.go index a1f99ea59..c7958b6e7 100644 --- a/test/e2e/suite/command/manifest.go +++ b/test/e2e/suite/command/manifest.go @@ -375,6 +375,19 @@ var _ = Describe("1.1 registry users:", func() { WithInput(strings.NewReader(manifest)).Exec() }) + It("should push a manifest and add multiple tags to it", func() { + repo := fmt.Sprintf(repoFmt, "push", "multi-tags") + CopyZOTRepo(ImageRepo, repo) + // test + ORAS("manifest", "push", fmt.Sprintf("%s,t2,t3", RegistryRef(ZOTHost, repo, "t1")), "-"). + WithInput(strings.NewReader(manifest)). + Exec() + // verify + ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, "t1")).Exec() + ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, "t2")).Exec() + ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, "t3")).Exec() + }) + It("should push a manifest from file", func() { manifestPath := WriteTempFile("manifest.json", manifest) tag := "from-file"