diff --git a/cmd/oras/internal/command/logger.go b/cmd/oras/internal/command/logger.go index 5492ea3d8..1d5c54e2c 100644 --- a/cmd/oras/internal/command/logger.go +++ b/cmd/oras/internal/command/logger.go @@ -26,7 +26,7 @@ import ( // GetLogger returns a new FieldLogger and an associated Context derived from command context. func GetLogger(cmd *cobra.Command, opts *option.Common) (context.Context, logrus.FieldLogger) { - ctx, logger := trace.NewLogger(cmd.Context(), opts.Debug, opts.Verbose) + ctx, logger := trace.NewLogger(cmd.Context(), opts.Debug) cmd.SetContext(ctx) return ctx, logger } diff --git a/cmd/oras/internal/display/handler_test.go b/cmd/oras/internal/display/handler_test.go index f1016e6f0..e02d1cfca 100644 --- a/cmd/oras/internal/display/handler_test.go +++ b/cmd/oras/internal/display/handler_test.go @@ -16,17 +16,18 @@ limitations under the License. package display import ( - "oras.land/oras/internal/testutils" "os" "testing" + "oras.land/oras/internal/testutils" + "oras.land/oras/cmd/oras/internal/option" "oras.land/oras/cmd/oras/internal/output" ) func TestNewPushHandler(t *testing.T) { mockFetcher := testutils.NewMockFetcher() - printer := output.NewPrinter(os.Stdout, os.Stderr, false) + printer := output.NewPrinter(os.Stdout, os.Stderr) _, _, err := NewPushHandler(printer, option.Format{Type: option.FormatTypeText.Name}, os.Stdout, mockFetcher.Fetcher) if err != nil { t.Errorf("NewPushHandler() error = %v, want nil", err) @@ -35,7 +36,7 @@ func TestNewPushHandler(t *testing.T) { func TestNewAttachHandler(t *testing.T) { mockFetcher := testutils.NewMockFetcher() - printer := output.NewPrinter(os.Stdout, os.Stderr, false) + printer := output.NewPrinter(os.Stdout, os.Stderr) _, _, err := NewAttachHandler(printer, option.Format{Type: option.FormatTypeText.Name}, os.Stdout, mockFetcher.Fetcher) if err != nil { t.Errorf("NewAttachHandler() error = %v, want nil", err) @@ -43,7 +44,7 @@ func TestNewAttachHandler(t *testing.T) { } func TestNewPullHandler(t *testing.T) { - printer := output.NewPrinter(os.Stdout, os.Stderr, false) + printer := output.NewPrinter(os.Stdout, os.Stderr) _, _, err := NewPullHandler(printer, option.Format{Type: option.FormatTypeText.Name}, "", os.Stdout) if err != nil { t.Errorf("NewPullHandler() error = %v, want nil", err) diff --git a/cmd/oras/internal/display/metadata/text/push_test.go b/cmd/oras/internal/display/metadata/text/push_test.go index c72a0a3e5..960de4134 100644 --- a/cmd/oras/internal/display/metadata/text/push_test.go +++ b/cmd/oras/internal/display/metadata/text/push_test.go @@ -65,7 +65,7 @@ func TestPushHandler_OnCompleted(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - printer := output.NewPrinter(tt.out, os.Stderr, false) + printer := output.NewPrinter(tt.out, os.Stderr) p := &PushHandler{ printer: printer, } diff --git a/cmd/oras/internal/display/status/text.go b/cmd/oras/internal/display/status/text.go index 76b54f09d..a103cfd40 100644 --- a/cmd/oras/internal/display/status/text.go +++ b/cmd/oras/internal/display/status/text.go @@ -49,7 +49,7 @@ func NewTextPushHandler(printer *output.Printer, fetcher content.Fetcher) PushHa // OnFileLoading is called when a file is being prepared for upload. func (ph *TextPushHandler) OnFileLoading(name string) error { - return ph.printer.PrintVerbose("Preparing", name) + return ph.printer.Println("Preparing", name) } // OnEmptyArtifact is called when an empty artifact is being uploaded. diff --git a/cmd/oras/internal/display/status/text_test.go b/cmd/oras/internal/display/status/text_test.go index 223bc69da..5f29e3a00 100644 --- a/cmd/oras/internal/display/status/text_test.go +++ b/cmd/oras/internal/display/status/text_test.go @@ -39,7 +39,7 @@ func TestMain(m *testing.M) { mockFetcher = testutils.NewMockFetcher() ctx = context.Background() builder = &strings.Builder{} - printer = output.NewPrinter(builder, os.Stderr, false) + printer = output.NewPrinter(builder, os.Stderr) bogus = ocispec.Descriptor{MediaType: ocispec.MediaTypeImageManifest} os.Exit(m.Run()) } @@ -173,7 +173,7 @@ func TestTextPushHandler_OnFileLoading(t *testing.T) { if ph.OnFileLoading("name") != nil { t.Error("OnFileLoading() should not return an error") } - validatePrinted(t, "") + validatePrinted(t, "Preparing name") } func TestTextPushHandler_PostCopy(t *testing.T) { @@ -204,14 +204,14 @@ func TestTextManifestIndexUpdateHandler_OnManifestAdded(t *testing.T) { }{ { name: "ref is a digest", - printer: output.NewPrinter(os.Stdout, os.Stderr, false), + printer: output.NewPrinter(os.Stdout, os.Stderr), ref: "sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb", desc: ocispec.Descriptor{MediaType: "test", Digest: "sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb", Size: 25}, wantErr: false, }, { name: "ref is not a digest", - printer: output.NewPrinter(os.Stdout, os.Stderr, false), + printer: output.NewPrinter(os.Stdout, os.Stderr), ref: "v1", desc: ocispec.Descriptor{MediaType: "test", Digest: "sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb", Size: 25}, wantErr: false, @@ -239,14 +239,14 @@ func TestTextManifestIndexUpdateHandler_OnIndexMerged(t *testing.T) { }{ { name: "ref is a digest", - printer: output.NewPrinter(os.Stdout, os.Stderr, false), + printer: output.NewPrinter(os.Stdout, os.Stderr), ref: "sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb", desc: ocispec.Descriptor{MediaType: "test", Digest: "sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb", Size: 25}, wantErr: false, }, { name: "ref is not a digest", - printer: output.NewPrinter(os.Stdout, os.Stderr, false), + printer: output.NewPrinter(os.Stdout, os.Stderr), ref: "v1", desc: ocispec.Descriptor{MediaType: "test", Digest: "sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb", Size: 25}, wantErr: false, diff --git a/cmd/oras/internal/option/common.go b/cmd/oras/internal/option/common.go index 3fa6cefde..ec09d3ec1 100644 --- a/cmd/oras/internal/option/common.go +++ b/cmd/oras/internal/option/common.go @@ -28,23 +28,22 @@ const NoTTYFlag = "no-tty" // Common option struct. type Common struct { - Debug bool - Verbose bool - TTY *os.File - *output.Printer + Debug bool noTTY bool + + TTY *os.File + *output.Printer } // ApplyFlags applies flags to a command flag set. func (opts *Common) ApplyFlags(fs *pflag.FlagSet) { fs.BoolVarP(&opts.Debug, "debug", "d", false, "output debug logs (implies --no-tty)") - fs.BoolVarP(&opts.Verbose, "verbose", "v", false, "verbose output") fs.BoolVarP(&opts.noTTY, NoTTYFlag, "", false, "[Preview] do not show progress output") } // Parse gets target options from user input. func (opts *Common) Parse(cmd *cobra.Command) error { - opts.Printer = output.NewPrinter(cmd.OutOrStdout(), cmd.OutOrStderr(), opts.Verbose) + opts.Printer = output.NewPrinter(cmd.OutOrStdout(), cmd.OutOrStderr()) // use STDERR as TTY output since STDOUT is reserved for pipeable output return opts.parseTTY(os.Stderr) } diff --git a/cmd/oras/internal/output/print.go b/cmd/oras/internal/output/print.go index d7e486866..39e7ba555 100644 --- a/cmd/oras/internal/output/print.go +++ b/cmd/oras/internal/output/print.go @@ -27,15 +27,14 @@ import ( // Printer prints for status handlers. type Printer struct { - out io.Writer - err io.Writer - verbose bool - lock sync.Mutex + out io.Writer + err io.Writer + lock sync.Mutex } // NewPrinter creates a new Printer. -func NewPrinter(out io.Writer, err io.Writer, verbose bool) *Printer { - return &Printer{out: out, err: err, verbose: verbose} +func NewPrinter(out io.Writer, err io.Writer) *Printer { + return &Printer{out: out, err: err} } // Write implements the io.Writer interface. @@ -71,19 +70,15 @@ func (p *Printer) Printf(format string, a ...any) error { return nil } -// PrintVerbose prints when verbose is true. -func (p *Printer) PrintVerbose(a ...any) error { - if !p.verbose { - return nil - } - return p.Println(a...) -} - // PrintStatus prints transfer status. func (p *Printer) PrintStatus(desc ocispec.Descriptor, status string) error { - name, isTitle := descriptor.GetTitleOrMediaType(desc) - if !isTitle { - return p.PrintVerbose(status, descriptor.ShortDigest(desc), name) + return p.Println(status, descriptor.ShortDigest(desc), descriptor.GetName(desc)) +} + +// PrintStatusUnlessSuppressed prints transfer status unless suppressed. +func (p *Printer) PrintStatusUnlessSuppressed(desc ocispec.Descriptor, status string, suppressed bool) error { + if suppressed { + return nil } - return p.Println(status, descriptor.ShortDigest(desc), name) + return p.PrintStatus(desc, status) } diff --git a/cmd/oras/internal/output/print_test.go b/cmd/oras/internal/output/print_test.go index 24ff6eb85..d695e4c4f 100644 --- a/cmd/oras/internal/output/print_test.go +++ b/cmd/oras/internal/output/print_test.go @@ -43,7 +43,7 @@ func (mw *mockWriter) String() string { func TestPrinter_Println(t *testing.T) { mockWriter := &mockWriter{} - printer := NewPrinter(mockWriter, os.Stderr, false) + printer := NewPrinter(mockWriter, os.Stderr) err := printer.Println("boom") if mockWriter.errorCount != 1 { t.Error("Expected one error actual <" + strconv.Itoa(mockWriter.errorCount) + ">") @@ -59,45 +59,3 @@ func TestPrinter_Println(t *testing.T) { t.Error("Expected error to be ignored") } } - -func TestPrinter_PrintVerbose_noError(t *testing.T) { - builder := &strings.Builder{} - printer := NewPrinter(builder, os.Stderr, false) - - expected := "normal\nthing one\n" - err := printer.Println("normal") - if err != nil { - t.Error("Expected no error got <" + err.Error() + ">") - } - err = printer.Printf("thing %s\n", "one") - if err != nil { - t.Error("Expected no error got <" + err.Error() + ">") - } - err = printer.PrintVerbose("verbose") - if err != nil { - t.Error("Expected no error got <" + err.Error() + ">") - } - actual := builder.String() - if expected != actual { - t.Error("Expected <" + expected + "> not equal to actual <" + actual + ">") - } -} - -func TestPrinter_PrintVerbose(t *testing.T) { - builder := &strings.Builder{} - printer := NewPrinter(builder, os.Stderr, true) - - expected := "normal\nverbose\n" - err := printer.Println("normal") - if err != nil { - t.Error("Expected no error got <" + err.Error() + ">") - } - err = printer.PrintVerbose("verbose") - if err != nil { - t.Error("Expected no error got <" + err.Error() + ">") - } - actual := builder.String() - if expected != actual { - t.Error("Expected <" + expected + "> not equal to actual <" + actual + ">") - } -} diff --git a/cmd/oras/root/attach.go b/cmd/oras/root/attach.go index 1531927d5..c0e00f229 100644 --- a/cmd/oras/root/attach.go +++ b/cmd/oras/root/attach.go @@ -42,6 +42,9 @@ type attachOptions struct { option.Format option.Platform + // Verbose is deprecated. The default behavior is now equivalent to + // Verbose=true, while Verbose=false no longer takes effect. + Verbose bool artifactType string concurrency int } @@ -113,9 +116,12 @@ Example - Attach file to the manifest tagged 'v1' in an OCI image layout folder }, } + opts.FlagDescription = "[Preview] attach to an arch-specific subject" cmd.Flags().StringVarP(&opts.artifactType, "artifact-type", "", "", "artifact type") cmd.Flags().IntVarP(&opts.concurrency, "concurrency", "", 5, "concurrency level") - opts.FlagDescription = "[Preview] attach to an arch-specific subject" + cmd.Flags().BoolVarP(&opts.Verbose, "verbose", "v", false, "[Deprecated] verbose output") + + _ = cmd.Flags().MarkDeprecated("verbose", "and may be removed in a future release.") _ = cmd.MarkFlagRequired("artifact-type") opts.EnableDistributionSpecFlag() opts.SetTypes(option.FormatTypeText, option.FormatTypeJSON, option.FormatTypeGoTemplate) diff --git a/cmd/oras/root/blob/push.go b/cmd/oras/root/blob/push.go index 6bb126357..bd255d260 100644 --- a/cmd/oras/root/blob/push.go +++ b/cmd/oras/root/blob/push.go @@ -39,6 +39,9 @@ type pushBlobOptions struct { option.Pretty option.Target + // Verbose is deprecated. The default behavior is now equivalent to + // Verbose=true, while Verbose=false no longer takes effect. + Verbose bool fileRef string mediaType string size int64 @@ -87,7 +90,6 @@ Example - Push blob 'hi.txt' into an OCI image layout folder 'layout-dir': return errors.New("`--size` must be provided if the blob is read from stdin") } } - opts.Verbose = opts.Verbose && !opts.OutputDescriptor return option.Parse(cmd, &opts) }, RunE: func(cmd *cobra.Command, args []string) error { @@ -97,6 +99,9 @@ Example - Push blob 'hi.txt' into an OCI image layout folder 'layout-dir': cmd.Flags().Int64VarP(&opts.size, "size", "", -1, "provide the blob size") cmd.Flags().StringVarP(&opts.mediaType, "media-type", "", ocispec.MediaTypeImageLayer, "specify the returned media type in the descriptor if --descriptor is used") + cmd.Flags().BoolVarP(&opts.Verbose, "verbose", "v", false, "[Deprecated] verbose output") + _ = cmd.Flags().MarkDeprecated("verbose", "and may be removed in a future release.") + option.ApplyFlags(&opts, cmd.Flags()) return oerrors.Command(cmd, &opts.Target) } @@ -121,9 +126,9 @@ func pushBlob(cmd *cobra.Command, opts *pushBlobOptions) (err error) { return err } if exists { - err = opts.PrintStatus(desc, "Exists") + err = opts.PrintStatusUnlessSuppressed(desc, "Exists", opts.OutputDescriptor) } else { - err = opts.doPush(ctx, opts.Printer, target, desc, rc) + err = opts.doPush(ctx, opts.Printer, target, desc, rc, opts.OutputDescriptor) } if err != nil { return err @@ -142,16 +147,16 @@ func pushBlob(cmd *cobra.Command, opts *pushBlobOptions) (err error) { return nil } -func (opts *pushBlobOptions) doPush(ctx context.Context, printer *output.Printer, t oras.Target, desc ocispec.Descriptor, r io.Reader) error { +func (opts *pushBlobOptions) doPush(ctx context.Context, printer *output.Printer, t oras.Target, desc ocispec.Descriptor, r io.Reader, statusSuppressed bool) error { if opts.TTY == nil { // none TTY output - if err := printer.PrintStatus(desc, "Uploading"); err != nil { + if err := printer.PrintStatusUnlessSuppressed(desc, "Uploading", statusSuppressed); err != nil { return err } if err := t.Push(ctx, desc, r); err != nil { return err } - return printer.PrintStatus(desc, "Uploaded ") + return printer.PrintStatusUnlessSuppressed(desc, "Uploaded ", statusSuppressed) } // TTY output diff --git a/cmd/oras/root/blob/push_test.go b/cmd/oras/root/blob/push_test.go index 154f3ae61..30424bd58 100644 --- a/cmd/oras/root/blob/push_test.go +++ b/cmd/oras/root/blob/push_test.go @@ -20,10 +20,11 @@ package blob import ( "bytes" "context" - "oras.land/oras/cmd/oras/internal/output" "os" "testing" + "oras.land/oras/cmd/oras/internal/output" + "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2/content/memory" @@ -40,7 +41,7 @@ func Test_pushBlobOptions_doPush(t *testing.T) { src := memory.New() content := []byte("test") r := bytes.NewReader(content) - printer := output.NewPrinter(os.Stdout, os.Stderr, false) + printer := output.NewPrinter(os.Stdout, os.Stderr) desc := ocispec.Descriptor{ MediaType: "application/octet-stream", Digest: digest.FromBytes(content), @@ -49,7 +50,7 @@ func Test_pushBlobOptions_doPush(t *testing.T) { var opts pushBlobOptions opts.Common.TTY = device // test - err = opts.doPush(context.Background(), printer, src, desc, r) + err = opts.doPush(context.Background(), printer, src, desc, r, false) if err != nil { t.Fatal(err) } diff --git a/cmd/oras/root/cp.go b/cmd/oras/root/cp.go index 8cf5ac250..63b45c0c0 100644 --- a/cmd/oras/root/cp.go +++ b/cmd/oras/root/cp.go @@ -50,6 +50,9 @@ type copyOptions struct { option.Platform option.BinaryTarget + // Verbose is deprecated. The default behavior is now equivalent to + // Verbose=true, while Verbose=false no longer takes effect. + Verbose bool recursive bool concurrency int extraRefs []string @@ -105,6 +108,9 @@ Example - Copy an artifact with multiple tags with concurrency tuned: } cmd.Flags().BoolVarP(&opts.recursive, "recursive", "r", false, "[Preview] recursively copy the artifact and its referrer artifacts") cmd.Flags().IntVarP(&opts.concurrency, "concurrency", "", 3, "concurrency level") + cmd.Flags().BoolVarP(&opts.Verbose, "verbose", "v", false, "[Deprecated] verbose output") + _ = cmd.Flags().MarkDeprecated("verbose", "and may be removed in a future release.") + opts.EnableDistributionSpecFlag() option.ApplyFlags(&opts, cmd.Flags()) return oerrors.Command(cmd, &opts.BinaryTarget) diff --git a/cmd/oras/root/cp_test.go b/cmd/oras/root/cp_test.go index c02ef5ea1..d37ceb6a1 100644 --- a/cmd/oras/root/cp_test.go +++ b/cmd/oras/root/cp_test.go @@ -24,12 +24,13 @@ import ( "net/http" "net/http/httptest" "net/url" - "oras.land/oras/cmd/oras/internal/display/status" - "oras.land/oras/cmd/oras/internal/output" "os" "strings" "testing" + "oras.land/oras/cmd/oras/internal/display/status" + "oras.land/oras/cmd/oras/internal/output" + "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2/content/memory" @@ -129,11 +130,10 @@ func Test_doCopy(t *testing.T) { defer slave.Close() var opts copyOptions opts.TTY = slave - opts.Verbose = true opts.From.Reference = memDesc.Digest.String() dst := memory.New() builder := &strings.Builder{} - printer := output.NewPrinter(builder, os.Stderr, opts.Verbose) + printer := output.NewPrinter(builder, os.Stderr) handler := status.NewTextCopyHandler(printer, dst) // test _, err = doCopy(context.Background(), handler, memStore, dst, &opts) @@ -155,10 +155,9 @@ func Test_doCopy_skipped(t *testing.T) { defer slave.Close() var opts copyOptions opts.TTY = slave - opts.Verbose = true opts.From.Reference = memDesc.Digest.String() builder := &strings.Builder{} - printer := output.NewPrinter(builder, os.Stderr, opts.Verbose) + printer := output.NewPrinter(builder, os.Stderr) handler := status.NewTextCopyHandler(printer, memStore) // test @@ -181,7 +180,6 @@ func Test_doCopy_mounted(t *testing.T) { defer slave.Close() var opts copyOptions opts.TTY = slave - opts.Verbose = true opts.From.Reference = manifestDigest // mocked repositories from, err := remote.NewRepository(fmt.Sprintf("%s/%s", host, repoFrom)) @@ -195,7 +193,7 @@ func Test_doCopy_mounted(t *testing.T) { } to.PlainHTTP = true builder := &strings.Builder{} - printer := output.NewPrinter(builder, os.Stderr, opts.Verbose) + printer := output.NewPrinter(builder, os.Stderr) handler := status.NewTextCopyHandler(printer, to) // test diff --git a/cmd/oras/root/discover.go b/cmd/oras/root/discover.go index 34d3bccb0..ab66447de 100644 --- a/cmd/oras/root/discover.go +++ b/cmd/oras/root/discover.go @@ -38,6 +38,7 @@ type discoverOptions struct { option.Platform option.Target option.Format + Verbose bool artifactType string } @@ -101,6 +102,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().BoolVarP(&opts.Verbose, "verbose", "v", false, "display full metadata of referrers") opts.SetTypes( option.FormatTypeTree, option.FormatTypeTable, diff --git a/cmd/oras/root/manifest/push.go b/cmd/oras/root/manifest/push.go index 78f61ece8..27000c425 100644 --- a/cmd/oras/root/manifest/push.go +++ b/cmd/oras/root/manifest/push.go @@ -44,6 +44,9 @@ type pushOptions struct { option.Pretty option.Target + // Verbose is deprecated. The default behavior is now equivalent to + // Verbose=true, while Verbose=false no longer takes effect. + Verbose bool concurrency int extraRefs []string fileRef string @@ -96,7 +99,6 @@ Example - Push a manifest to an OCI image layout folder 'layout-dir' and tag wit refs := strings.Split(args[0], ",") opts.RawReference = refs[0] opts.extraRefs = refs[1:] - opts.Verbose = opts.Verbose && !opts.OutputDescriptor return option.Parse(cmd, &opts) }, RunE: func(cmd *cobra.Command, args []string) error { @@ -108,6 +110,9 @@ Example - Push a manifest to an OCI image layout folder 'layout-dir' and tag wit option.ApplyFlags(&opts, cmd.Flags()) cmd.Flags().StringVarP(&opts.mediaType, "media-type", "", "", "media type of manifest") cmd.Flags().IntVarP(&opts.concurrency, "concurrency", "", 5, "concurrency level") + cmd.Flags().BoolVarP(&opts.Verbose, "verbose", "v", false, "[Deprecated] verbose output") + _ = cmd.Flags().MarkDeprecated("verbose", "and may be removed in a future release.") + return oerrors.Command(cmd, &opts.Target) } @@ -157,17 +162,17 @@ func pushManifest(cmd *cobra.Command, opts pushOptions) error { return err } if match { - if err := opts.PrintStatus(desc, "Exists"); err != nil { + if err := opts.PrintStatusUnlessSuppressed(desc, "Exists", opts.OutputDescriptor); err != nil { return err } } else { - if err = opts.PrintStatus(desc, "Uploading"); err != nil { + if err = opts.PrintStatusUnlessSuppressed(desc, "Uploading", opts.OutputDescriptor); err != nil { return err } if _, err := oras.TagBytes(ctx, target, mediaType, contentBytes, ref); err != nil { return err } - if err = opts.PrintStatus(desc, "Uploaded "); err != nil { + if err = opts.PrintStatusUnlessSuppressed(desc, "Uploaded ", opts.OutputDescriptor); err != nil { return err } } diff --git a/cmd/oras/root/pull.go b/cmd/oras/root/pull.go index 6ab3a3dff..e267a97b4 100644 --- a/cmd/oras/root/pull.go +++ b/cmd/oras/root/pull.go @@ -52,6 +52,9 @@ type pullOptions struct { PathTraversal bool Output string ManifestConfigRef string + // Verbose is deprecated. The default behavior is now equivalent to + // Verbose=true, while Verbose=false no longer takes effect. + Verbose bool } func pullCmd() *cobra.Command { @@ -111,6 +114,9 @@ Example - Pull artifact files from an OCI layout archive 'layout.tar': cmd.Flags().StringVarP(&opts.Output, "output", "o", ".", "output directory") cmd.Flags().StringVarP(&opts.ManifestConfigRef, "config", "", "", "output manifest config file") cmd.Flags().IntVarP(&opts.concurrency, "concurrency", "", 3, "concurrency level") + cmd.Flags().BoolVarP(&opts.Verbose, "verbose", "v", false, "[Deprecated] verbose output") + _ = cmd.Flags().MarkDeprecated("verbose", "and may be removed in a future release.") + opts.SetTypes(option.FormatTypeText, option.FormatTypeJSON, option.FormatTypeGoTemplate) option.ApplyFlags(&opts, cmd.Flags()) return oerrors.Command(cmd, &opts.Target) diff --git a/cmd/oras/root/push.go b/cmd/oras/root/push.go index b5ae07e14..f21493e5d 100644 --- a/cmd/oras/root/push.go +++ b/cmd/oras/root/push.go @@ -47,6 +47,9 @@ type pushOptions struct { option.ImageSpec option.Target option.Format + // Verbose is deprecated. The default behavior is now equivalent to + // Verbose=true, while Verbose=false no longer takes effect. + Verbose bool extraRefs []string manifestConfigRef string @@ -163,6 +166,9 @@ Example - Push file "hi.txt" into an OCI image layout folder 'layout-dir' with t cmd.Flags().StringVarP(&opts.manifestConfigRef, "config", "", "", "`path` of image config file") cmd.Flags().StringVarP(&opts.artifactType, "artifact-type", "", "", "artifact type") cmd.Flags().IntVarP(&opts.concurrency, "concurrency", "", 5, "concurrency level") + cmd.Flags().BoolVarP(&opts.Verbose, "verbose", "v", false, "[Deprecated] verbose output") + _ = cmd.Flags().MarkDeprecated("verbose", "and may be removed in a future release.") + opts.SetTypes(option.FormatTypeText, option.FormatTypeJSON, option.FormatTypeGoTemplate) option.ApplyFlags(&opts, cmd.Flags()) return oerrors.Command(cmd, &opts.Target) diff --git a/cmd/oras/root/version.go b/cmd/oras/root/version.go index 908f46f56..fb4f510ec 100644 --- a/cmd/oras/root/version.go +++ b/cmd/oras/root/version.go @@ -46,7 +46,7 @@ Example - print version: return nil }, RunE: func(cmd *cobra.Command, args []string) error { - printer := output.NewPrinter(cmd.OutOrStdout(), cmd.ErrOrStderr(), false) + printer := output.NewPrinter(cmd.OutOrStdout(), cmd.ErrOrStderr()) return runVersion(printer) }, } diff --git a/internal/descriptor/descriptor.go b/internal/descriptor/descriptor.go index 41f7321b7..741aa3c94 100644 --- a/internal/descriptor/descriptor.go +++ b/internal/descriptor/descriptor.go @@ -66,13 +66,13 @@ func Plain(desc ocispec.Descriptor) ocispec.Descriptor { } } -// GetTitleOrMediaType gets a descriptor name using either title or media type. -func GetTitleOrMediaType(desc ocispec.Descriptor) (name string, isTitle bool) { - name, ok := desc.Annotations[ocispec.AnnotationTitle] - if !ok { - return desc.MediaType, false +// GetName gets a descriptor name using either title or media type. +func GetName(desc ocispec.Descriptor) string { + title, ok := desc.Annotations[ocispec.AnnotationTitle] + if ok { + return title } - return name, true + return desc.MediaType } // GenerateContentKey generates a unique key for each content descriptor using diff --git a/internal/descriptor/descriptor_test.go b/internal/descriptor/descriptor_test.go index 392bfa671..8a5f25a4a 100644 --- a/internal/descriptor/descriptor_test.go +++ b/internal/descriptor/descriptor_test.go @@ -78,22 +78,16 @@ func TestDescriptor_ShortDigest(t *testing.T) { func TestDescriptor_GetTitleOrMediaType(t *testing.T) { expected := "application/vnd.oci.image.manifest.v1+json" - name, isTitle := descriptor.GetTitleOrMediaType(imageDesc) + name := descriptor.GetName(imageDesc) if expected != name { t.Fatalf("GetTitleOrMediaType() got %v, want %v", name, expected) } - if false != isTitle { - t.Fatalf("GetTitleOrMediaType() got %v, want %v", isTitle, false) - } expected = "shaboozey" - name, isTitle = descriptor.GetTitleOrMediaType(titledDesc) + name = descriptor.GetName(titledDesc) if expected != name { t.Fatalf("GetTitleOrMediaType() got %v, want %v", name, expected) } - if true != isTitle { - t.Fatalf("GetTitleOrMediaType() got %v, want %v", isTitle, false) - } } func TestDescriptor_GenerateContentKey(t *testing.T) { diff --git a/internal/trace/context.go b/internal/trace/context.go index d1299e6f1..d55c3812d 100644 --- a/internal/trace/context.go +++ b/internal/trace/context.go @@ -27,12 +27,10 @@ type contextKey int const loggerKey contextKey = iota // NewLogger returns a logger. -func NewLogger(ctx context.Context, debug bool, verbose bool) (context.Context, logrus.FieldLogger) { +func NewLogger(ctx context.Context, debug bool) (context.Context, logrus.FieldLogger) { var logLevel logrus.Level if debug { logLevel = logrus.DebugLevel - } else if verbose { - logLevel = logrus.InfoLevel } else { logLevel = logrus.WarnLevel } diff --git a/test/e2e/suite/auth/auth.go b/test/e2e/suite/auth/auth.go index 8e82b7937..98d017fda 100644 --- a/test/e2e/suite/auth/auth.go +++ b/test/e2e/suite/auth/auth.go @@ -179,7 +179,7 @@ var _ = Describe("Common registry user", func() { src := RegistryRef(ZOTHost, ArtifactRepo, foobar.Tag) dst := RegistryRef(ZOTHost, fmt.Sprintf("command/auth/%d/copy", GinkgoRandomSeed()), foobar.Tag) foobarStates := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(oras.MediaTypeUnknownConfig)) - ORAS("cp", src, dst, "-v", "--from-registry-config", LegacyConfigPath, "--to-registry-config", LegacyConfigPath).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dst, "--from-registry-config", LegacyConfigPath, "--to-registry-config", LegacyConfigPath).MatchStatus(foobarStates, true, len(foobarStates)).Exec() }) }) }) diff --git a/test/e2e/suite/command/blob.go b/test/e2e/suite/command/blob.go index 717a7d366..ab9815ff1 100644 --- a/test/e2e/suite/command/blob.go +++ b/test/e2e/suite/command/blob.go @@ -236,7 +236,7 @@ var _ = Describe("1.1 registry users:", func() { MatchContent(fmt.Sprintf(pushDescFmt, mediaType)).Exec() ORAS("blob", "fetch", RegistryRef(ZOTHost, repo, pushDigest), "--output", "-").MatchContent(pushContent).Exec() - ORAS("blob", "push", RegistryRef(ZOTHost, repo, ""), blobPath, "-v"). + ORAS("blob", "push", RegistryRef(ZOTHost, repo, ""), blobPath). WithDescription("skip the pushing if the blob already exists in the target repo"). MatchKeyWords("Exists").Exec() }) @@ -347,7 +347,7 @@ var _ = Describe("OCI image layout users:", func() { // test ORAS("blob", "push", Flags.Layout, LayoutRef(tmpRoot, pushDigest), blobPath, "--media-type", mediaType, "--descriptor"). MatchContent(fmt.Sprintf(pushDescFmt, mediaType)).Exec() - ORAS("blob", "push", Flags.Layout, LayoutRef(tmpRoot, pushDigest), blobPath, "-v"). + ORAS("blob", "push", Flags.Layout, LayoutRef(tmpRoot, pushDigest), blobPath). WithDescription("skip pushing if the blob already exists in the target repo"). MatchKeyWords("Exists").Exec() // validate diff --git a/test/e2e/suite/command/cp.go b/test/e2e/suite/command/cp.go index 70b278f64..ca11b75fd 100644 --- a/test/e2e/suite/command/cp.go +++ b/test/e2e/suite/command/cp.go @@ -121,7 +121,7 @@ var _ = Describe("1.1 registry users:", func() { It("should copy an artifact with blob", func() { src := RegistryRef(ZOTHost, ArtifactRepo, blob.Tag) dst := RegistryRef(ZOTHost, cpTestRepo("artifact-with-blob"), "copied") - ORAS("cp", src, dst, "-v").MatchStatus(blob.StateKeys, true, len(blob.StateKeys)).Exec() + ORAS("cp", src, dst).MatchStatus(blob.StateKeys, true, len(blob.StateKeys)).Exec() CompareRef(src, dst) }) @@ -137,34 +137,34 @@ var _ = Describe("1.1 registry users:", func() { It("should copy an artifact with config", func() { src := RegistryRef(ZOTHost, ArtifactRepo, config.Tag) dst := RegistryRef(ZOTHost, cpTestRepo("artifact-with-config"), "copied") - ORAS("cp", src, dst, "-v").MatchStatus(config.StateKeys, true, len(config.StateKeys)).Exec() + ORAS("cp", src, dst).MatchStatus(config.StateKeys, true, len(config.StateKeys)).Exec() }) It("should copy index and its subject", func() { stateKeys := append(ma.IndexStateKeys, index.ManifestStatusKey) src := RegistryRef(ZOTHost, ArtifactRepo, index.ManifestDigest) dst := RegistryRef(ZOTHost, cpTestRepo("index-with-subject"), "") - ORAS("cp", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() + ORAS("cp", src, dst).MatchStatus(stateKeys, true, len(stateKeys)).Exec() }) It("should copy an image to a new repository via tag", func() { src := RegistryRef(ZOTHost, ImageRepo, foobar.Tag) dst := RegistryRef(ZOTHost, cpTestRepo("tag"), "copied") - ORAS("cp", src, dst, "-v").MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dst).MatchStatus(foobarStates, true, len(foobarStates)).Exec() CompareRef(src, dst) }) It("should copy an image to a new repository via digest", func() { src := RegistryRef(ZOTHost, ImageRepo, foobar.Digest) dst := RegistryRef(ZOTHost, cpTestRepo("digest"), "copiedTag") - ORAS("cp", src, dst, "-v").MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dst).MatchStatus(foobarStates, true, len(foobarStates)).Exec() CompareRef(src, dst) }) It("should copy an image to a new repository via tag without tagging", func() { src := RegistryRef(ZOTHost, ImageRepo, foobar.Tag) dst := RegistryRef(ZOTHost, cpTestRepo("no-tagging"), foobar.Digest) - ORAS("cp", src, dst, "-v").MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dst).MatchStatus(foobarStates, true, len(foobarStates)).Exec() CompareRef(src, dst) }) @@ -172,7 +172,7 @@ var _ = Describe("1.1 registry users:", func() { stateKeys := append(append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageReferrerConfigStateKeys[0]), foobar.ImageReferrersStateKeys...) src := RegistryRef(ZOTHost, ArtifactRepo, foobar.Tag) dst := RegistryRef(ZOTHost, cpTestRepo("referrers"), foobar.Digest) - ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() + ORAS("cp", "-r", src, dst).MatchStatus(stateKeys, true, len(stateKeys)).Exec() CompareRef(src, dst) }) @@ -181,7 +181,7 @@ var _ = Describe("1.1 registry users:", func() { src := RegistryRef(ZOTHost, ArtifactRepo, ma.Tag) dstRepo := cpTestRepo("index-referrers") dst := RegistryRef(ZOTHost, dstRepo, "copiedTag") - ORAS("cp", src, dst, "-r", "-v"). + ORAS("cp", src, dst, "-r"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.Digest). Exec() @@ -200,7 +200,7 @@ var _ = Describe("1.1 registry users:", func() { dstRepo := cpTestRepo("index-referrers-concurrent") dst := RegistryRef(ZOTHost, dstRepo, "copiedTag") // test - ORAS("cp", src, dst, "-r", "-v", "--concurrency", "0"). + ORAS("cp", src, dst, "-r", "--concurrency", "0"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.Digest). Exec() @@ -217,7 +217,7 @@ var _ = Describe("1.1 registry users:", func() { dstRepo := cpTestRepo("empty-index") dst := RegistryRef(ZOTHost, dstRepo, "copiedTag") // test - ORAS("cp", src, dst, "-r", "-v", "--concurrency", "0").Exec() + ORAS("cp", src, dst, "-r", "--concurrency", "0").Exec() // validate CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.EmptyTag), dst) }) @@ -227,7 +227,7 @@ var _ = Describe("1.1 registry users:", func() { src := RegistryRef(ZOTHost, ArtifactRepo, ma.Tag) dstRepo := cpTestRepo("index-referrers-digest") dst := RegistryRef(ZOTHost, dstRepo, ma.Digest) - ORAS("cp", src, dst, "-r", "-v"). + ORAS("cp", src, dst, "-r"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.Digest). Exec() @@ -243,7 +243,7 @@ var _ = Describe("1.1 registry users:", func() { src := RegistryRef(ZOTHost, ImageRepo, ma.Tag) dst := RegistryRef(ZOTHost, cpTestRepo("platform-tag"), "copiedTag") - ORAS("cp", src, dst, "--platform", "linux/amd64", "-v"). + ORAS("cp", src, dst, "--platform", "linux/amd64"). MatchStatus(ma.LinuxAMD64StateKeys, true, len(ma.LinuxAMD64StateKeys)). MatchKeyWords("Digest: " + ma.LinuxAMD64.Digest.String()). Exec() @@ -254,7 +254,7 @@ var _ = Describe("1.1 registry users:", func() { src := RegistryRef(ZOTHost, ImageRepo, ma.Digest) dstRepo := cpTestRepo("platform-digest") dst := RegistryRef(ZOTHost, dstRepo, "") - ORAS("cp", src, dst, "--platform", "linux/amd64", "-v"). + ORAS("cp", src, dst, "--platform", "linux/amd64"). MatchStatus(ma.LinuxAMD64StateKeys, true, len(ma.LinuxAMD64StateKeys)). MatchKeyWords("Digest: " + ma.LinuxAMD64.Digest.String()). Exec() @@ -267,7 +267,7 @@ var _ = Describe("1.1 registry users:", func() { dstRepo := cpTestRepo("platform-referrers") dst := RegistryRef(ZOTHost, dstRepo, "copiedTag") digest := ma.LinuxAMD64.Digest.String() - ORAS("cp", src, dst, "-r", "--platform", "linux/amd64", "-v"). + ORAS("cp", src, dst, "-r", "--platform", "linux/amd64"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + digest). Exec() @@ -285,7 +285,7 @@ var _ = Describe("1.1 registry users:", func() { dstRepo := cpTestRepo("platform-referrers-no-tag") dst := RegistryRef(ZOTHost, dstRepo, "") digest := ma.LinuxAMD64.Digest.String() - ORAS("cp", src, dst, "-r", "--platform", "linux/amd64", "-v"). + ORAS("cp", src, dst, "-r", "--platform", "linux/amd64"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + digest). Exec() @@ -302,7 +302,7 @@ var _ = Describe("1.1 registry users:", func() { tags := []string{"tag1", "tag2", "tag3"} dstRepo := cpTestRepo("multi-tagging") dst := RegistryRef(ZOTHost, dstRepo, "") - ORAS("cp", src, dst+":"+strings.Join(tags, ","), "-v").MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dst+":"+strings.Join(tags, ",")).MatchStatus(foobarStates, true, len(foobarStates)).Exec() for _, tag := range tags { dst := RegistryRef(ZOTHost, dstRepo, tag) CompareRef(src, dst) @@ -317,7 +317,7 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { repo := cpTestRepo("1.0-mount") src := RegistryRef(FallbackHost, ArtifactRepo, foobar.Tag) dst := RegistryRef(FallbackHost, repo, "") - out := ORAS("cp", src, dst, "-v").Exec() + out := ORAS("cp", src, dst).Exec() Expect(out).Should(gbytes.Say("Mounted fcde2b2edba5 bar")) CompareRef(src, RegistryRef(FallbackHost, repo, foobar.Digest)) }) @@ -327,7 +327,7 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { stateKeys := append(append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageReferrerConfigStateKeys[0]), foobar.ImageReferrersStateKeys...) src := RegistryRef(ZOTHost, ArtifactRepo, foobar.SignatureImageReferrer.Digest.String()) dst := RegistryRef(FallbackHost, repo, "") - ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() + ORAS("cp", "-r", src, dst).MatchStatus(stateKeys, true, len(stateKeys)).Exec() CompareRef(src, RegistryRef(FallbackHost, repo, foobar.SignatureImageReferrer.Digest.String())) ORAS("discover", "-o", "tree", RegistryRef(FallbackHost, repo, foobar.Digest)). WithDescription("discover referrer via subject").MatchKeyWords(foobar.SignatureImageReferrer.Digest.String(), foobar.SBOMImageReferrer.Digest.String()).Exec() @@ -337,7 +337,7 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { stateKeys := append(append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageReferrerConfigStateKeys[0]), foobar.ImageReferrersStateKeys...) src := RegistryRef(FallbackHost, ArtifactRepo, foobar.SBOMImageReferrer.Digest.String()) dst := RegistryRef(ZOTHost, repo, "") - ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() + ORAS("cp", "-r", src, dst).MatchStatus(stateKeys, true, len(stateKeys)).Exec() CompareRef(src, RegistryRef(ZOTHost, repo, foobar.SBOMImageReferrer.Digest.String())) ORAS("discover", "-o", "tree", RegistryRef(ZOTHost, repo, foobar.Digest)). WithDescription("discover referrer via subject").MatchKeyWords(foobar.SignatureImageReferrer.Digest.String(), foobar.SBOMImageReferrer.Digest.String()).Exec() @@ -346,7 +346,7 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { It("should copy an image from a fallback registry to an OCI image layout via digest", func() { dstDir := GinkgoT().TempDir() src := RegistryRef(FallbackHost, ArtifactRepo, foobar.Tag) - ORAS("cp", src, dstDir, "-v", Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dstDir, Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", LayoutRef(dstDir, foobar.Digest), Flags.Layout).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -360,7 +360,7 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { // prepare ORAS("cp", RegistryRef(FallbackHost, ArtifactRepo, foobar.Tag), layoutDir, Flags.ToLayout).Exec() // test - ORAS("cp", src, dst, "-v", Flags.FromLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dst, Flags.FromLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src, Flags.Layout).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", dst).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -377,7 +377,7 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { ORAS("cp", RegistryRef(ZOTHost, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r").Exec() ORAS("cp", RegistryRef(ZOTHost, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r", "--platform", "linux/amd64").Exec() // test - ORAS("cp", src, Flags.FromLayout, dst, "-r", "-v", "--platform", "linux/amd64"). + ORAS("cp", src, Flags.FromLayout, dst, "-r", "--platform", "linux/amd64"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.LinuxAMD64.Digest.String()). Exec() @@ -403,7 +403,7 @@ var _ = Describe("OCI layout users:", func() { It("should copy an image from a registry to an OCI image layout via tag", func() { dst := LayoutRef(GinkgoT().TempDir(), "copied") src := RegistryRef(ZOTHost, ImageRepo, foobar.Tag) - ORAS("cp", src, dst, "-v", Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dst, Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", dst, Flags.Layout).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -417,7 +417,7 @@ var _ = Describe("OCI layout users:", func() { // prepare ORAS("cp", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), src, Flags.ToLayout).Exec() // test - ORAS("cp", src, dst, "-v", Flags.FromLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dst, Flags.FromLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src, Flags.Layout).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", dst).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -432,7 +432,7 @@ var _ = Describe("OCI layout users:", func() { // prepare ORAS("cp", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), src, Flags.ToLayout).Exec() // test - ORAS("cp", src, dst, "-v", Flags.FromLayout, Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dst, Flags.FromLayout, Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src, Flags.Layout).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", dst, Flags.Layout).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -442,7 +442,7 @@ var _ = Describe("OCI layout users:", func() { It("should copy an image from a registry to an OCI image layout via digest", func() { dstDir := GinkgoT().TempDir() src := RegistryRef(ZOTHost, ImageRepo, foobar.Digest) - ORAS("cp", src, dstDir, "-v", Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dstDir, Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", LayoutRef(dstDir, foobar.Digest), Flags.Layout).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -456,7 +456,7 @@ var _ = Describe("OCI layout users:", func() { // prepare ORAS("cp", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), layoutDir, Flags.ToLayout).Exec() // test - ORAS("cp", src, dst, "-v", Flags.FromLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dst, Flags.FromLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src, Flags.Layout).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", dst).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -471,7 +471,7 @@ var _ = Describe("OCI layout users:", func() { // prepare ORAS("cp", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), srcDir, Flags.ToLayout).Exec() // test - ORAS("cp", src, toDir, "-v", Flags.FromLayout, Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, toDir, Flags.FromLayout, Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src, Flags.Layout).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", dst, Flags.Layout).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -483,7 +483,7 @@ var _ = Describe("OCI layout users:", func() { src := RegistryRef(ZOTHost, ImageRepo, foobar.Tag) tags := []string{"tag1", "tag2", "tag3"} // test - ORAS("cp", src, dstDir+":"+strings.Join(tags, ","), "-v", Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dstDir+":"+strings.Join(tags, ","), Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src).WithDescription("fetch from source to validate").Exec().Out.Contents() for _, tag := range tags { @@ -497,7 +497,7 @@ var _ = Describe("OCI layout users:", func() { dst := LayoutRef(GinkgoT().TempDir(), "copied") src := RegistryRef(ZOTHost, ArtifactRepo, foobar.Tag) // test - ORAS("cp", "-r", src, dst, "-v", Flags.ToLayout).MatchStatus(stateKeys, true, len(stateKeys)).Exec() + ORAS("cp", "-r", src, dst, Flags.ToLayout).MatchStatus(stateKeys, true, len(stateKeys)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", dst, Flags.Layout).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -509,7 +509,7 @@ var _ = Describe("OCI layout users:", func() { toDir := GinkgoT().TempDir() src := RegistryRef(ZOTHost, ArtifactRepo, foobar.Digest) // test - ORAS("cp", "-r", src, toDir, "-v", Flags.ToLayout).MatchStatus(stateKeys, true, len(stateKeys)).Exec() + ORAS("cp", "-r", src, toDir, Flags.ToLayout).MatchStatus(stateKeys, true, len(stateKeys)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", LayoutRef(toDir, foobar.Digest), Flags.Layout).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -522,7 +522,7 @@ var _ = Describe("OCI layout users:", func() { toDir := GinkgoT().TempDir() dst := LayoutRef(toDir, "copied") // test - ORAS("cp", src, Flags.ToLayout, dst, "-r", "-v"). + ORAS("cp", src, Flags.ToLayout, dst, "-r"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.Digest). Exec() @@ -551,7 +551,7 @@ var _ = Describe("OCI layout users:", func() { // prepare ORAS("cp", RegistryRef(ZOTHost, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r").Exec() // test - ORAS("cp", src, Flags.FromLayout, dst, "-r", "-v"). + ORAS("cp", src, Flags.FromLayout, dst, "-r"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.Digest). Exec() @@ -582,7 +582,7 @@ var _ = Describe("OCI layout users:", func() { ORAS("cp", RegistryRef(ZOTHost, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r").Exec() ORAS("cp", RegistryRef(ZOTHost, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r", "--platform", "linux/amd64").Exec() // test - ORAS("cp", src, Flags.FromLayout, dst, "-r", "-v", "--platform", "linux/amd64"). + ORAS("cp", src, Flags.FromLayout, dst, "-r", "--platform", "linux/amd64"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.LinuxAMD64.Digest.String()). Exec() @@ -607,7 +607,7 @@ var _ = Describe("OCI layout users:", func() { toDir := GinkgoT().TempDir() dst := LayoutRef(toDir, "copied") // test - ORAS("cp", src, Flags.ToLayout, dst, "-r", "-v", "--platform", "linux/amd64"). + ORAS("cp", src, Flags.ToLayout, dst, "-r", "--platform", "linux/amd64"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.LinuxAMD64.Digest.String()). Exec() @@ -633,7 +633,7 @@ var _ = Describe("OCI layout users:", func() { src := RegistryRef(ZOTHost, ImageRepo, foobar.Tag) ref := "copied" dst := LayoutRef(layoutDir, ref) - ORAS("cp", src, ref, "-v", Flags.ToLayoutPath, layoutDir).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, ref, Flags.ToLayoutPath, layoutDir).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", dst, Flags.Layout).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -648,7 +648,7 @@ var _ = Describe("OCI layout users:", func() { // prepare ORAS("cp", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), src, Flags.ToLayout).Exec() // test - ORAS("cp", ref, dst, "-v", Flags.FromLayoutPath, layoutDir).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", ref, dst, Flags.FromLayoutPath, layoutDir).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src, Flags.Layout).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", dst).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -665,7 +665,7 @@ var _ = Describe("OCI layout users:", func() { // prepare ORAS("cp", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), src, Flags.ToLayout).Exec() // test - ORAS("cp", srcRef, dstRef, "-v", Flags.FromLayoutPath, srcDir, Flags.ToLayoutPath, toDir).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", srcRef, dstRef, Flags.FromLayoutPath, srcDir, Flags.ToLayoutPath, toDir).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src, Flags.Layout).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", dst, Flags.Layout).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -675,7 +675,7 @@ var _ = Describe("OCI layout users:", func() { It("should copy an image from a registry to an OCI image layout via digest using --oci-layout-path", func() { dstDir := GinkgoT().TempDir() src := RegistryRef(ZOTHost, ImageRepo, foobar.Digest) - ORAS("cp", src, foobar.Digest, "-v", Flags.ToLayoutPath, dstDir).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, foobar.Digest, Flags.ToLayoutPath, dstDir).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", LayoutRef(dstDir, foobar.Digest), Flags.Layout).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -689,7 +689,7 @@ var _ = Describe("OCI layout users:", func() { // prepare ORAS("cp", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), layoutDir, Flags.ToLayout).Exec() // test - ORAS("cp", foobar.Digest, dst, "-v", Flags.FromLayoutPath, layoutDir).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", foobar.Digest, dst, Flags.FromLayoutPath, layoutDir).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src, Flags.Layout).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", dst).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -704,7 +704,7 @@ var _ = Describe("OCI layout users:", func() { // prepare ORAS("cp", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), srcDir, Flags.ToLayout).Exec() // test - ORAS("cp", foobar.Digest, foobar.Digest, "-v", Flags.FromLayoutPath, srcDir, Flags.ToLayoutPath, toDir).MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", foobar.Digest, foobar.Digest, Flags.FromLayoutPath, srcDir, Flags.ToLayoutPath, toDir).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src, Flags.Layout).WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", dst, Flags.Layout).WithDescription("fetch from destination to validate").Exec().Out.Contents() @@ -719,7 +719,7 @@ var _ = Describe("OCI image spec v1.1.0-rc2 artifact users:", func() { digest := foobar.SBOMArtifactReferrer.Digest.String() src := RegistryRef(Host, ArtifactRepo, digest) dst := RegistryRef(Host, cpTestRepo("referrers"), digest) - ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() + ORAS("cp", "-r", src, dst).MatchStatus(stateKeys, true, len(stateKeys)).Exec() CompareRef(src, dst) }) }) diff --git a/test/e2e/suite/command/pull.go b/test/e2e/suite/command/pull.go index d463cf582..f82398bb7 100644 --- a/test/e2e/suite/command/pull.go +++ b/test/e2e/suite/command/pull.go @@ -47,15 +47,30 @@ var _ = Describe("ORAS beginners:", func() { MatchDefaultFlagValue("format", "text", "pull") }) + It("should not show --verbose in help doc", func() { + out := ORAS("pull", "--help").MatchKeyWords(ExampleDesc).Exec().Out + gomega.Expect(out).ShouldNot(gbytes.Say("--verbose")) + }) + + It("should show deprecation message for --verbose", func() { + tempDir := PrepareTempFiles() + ref := RegistryRef(ZOTHost, ImageRepo, foobar.Tag) + stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey) + ORAS("pull", ref, "--verbose"). + WithWorkDir(tempDir). + MatchErrKeyWords("Flag --verbose has been deprecated"). + MatchStatus(stateKeys, true, len(stateKeys)). + Exec() + }) + hintMsg := func(reference string) string { return fmt.Sprintf("Skipped pulling layers without file name in \"org.opencontainers.image.title\"\nUse 'oras copy %s --to-oci-layout ' to pull all layers.\n", reference) } It("should show hint for unnamed layer", func() { tempDir := PrepareTempFiles() ref := RegistryRef(ZOTHost, ArtifactRepo, unnamed.Tag) - ORAS("pull", ref). - WithWorkDir(tempDir). - MatchContent(hintMsg(ref)).Exec() + out := ORAS("pull", ref).WithWorkDir(tempDir).Exec().Out + gomega.Expect(out).Should(gbytes.Say(hintMsg(ref))) }) It("should not show hint for unnamed config blob", func() { @@ -184,7 +199,7 @@ var _ = Describe("OCI spec 1.1 registry users:", func() { pullRoot := "pulled" tempDir := PrepareTempFiles() stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(configName)) - ORAS("pull", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "-v", "--config", configName, "-o", pullRoot). + ORAS("pull", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "--config", configName, "-o", pullRoot). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(tempDir).Exec() // check config @@ -200,7 +215,7 @@ var _ = Describe("OCI spec 1.1 registry users:", func() { WithWorkDir(tempDir).Exec() } - ORAS("pull", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files"). + ORAS("pull", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "-o", pullRoot, "--keep-old-files"). ExpectFailure(). WithDescription("fail if overwrite old files are disabled") }) @@ -209,7 +224,7 @@ var _ = Describe("OCI spec 1.1 registry users:", func() { pullRoot := "pulled" tempDir := PrepareTempFiles() stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey) - ORAS("pull", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "-v", "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot). + ORAS("pull", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(tempDir).Exec() // check config @@ -229,7 +244,7 @@ var _ = Describe("OCI spec 1.1 registry users:", func() { foobar.ManifestStateKey), foobar.ImageReferrersStateKeys..., ) - ORAS("pull", RegistryRef(ZOTHost, ArtifactRepo, foobar.SignatureImageReferrer.Digest.String()), "-v", "--include-subject"). + ORAS("pull", RegistryRef(ZOTHost, ArtifactRepo, foobar.SignatureImageReferrer.Digest.String()), "--include-subject"). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(tempDir).Exec() }) @@ -275,19 +290,19 @@ var _ = Describe("OCI spec 1.1 registry users:", func() { }) It("should pull specific platform", func() { - ORAS("pull", RegistryRef(ZOTHost, ImageRepo, "multi"), "--platform", "linux/amd64", "-v", "-o", GinkgoT().TempDir()). + ORAS("pull", RegistryRef(ZOTHost, ImageRepo, "multi"), "--platform", "linux/amd64", "-o", GinkgoT().TempDir()). MatchStatus(multi_arch.LinuxAMD64StateKeys, true, len(multi_arch.LinuxAMD64StateKeys)).Exec() }) It("should pull an artifact with blob", func() { pullRoot := GinkgoT().TempDir() - ORAS("pull", RegistryRef(ZOTHost, ArtifactRepo, blob.Tag), "-v", "-o", pullRoot).Exec() + ORAS("pull", RegistryRef(ZOTHost, ArtifactRepo, blob.Tag), "-o", pullRoot).Exec() Expect(filepath.Join(pullRoot, multi_arch.LayerName)).Should(BeAnExistingFile()) }) It("should pull an artifact with config", func() { pullRoot := GinkgoT().TempDir() - ORAS("pull", RegistryRef(ZOTHost, ArtifactRepo, config.Tag), "-v", "-o", pullRoot).Exec() + ORAS("pull", RegistryRef(ZOTHost, ArtifactRepo, config.Tag), "-o", pullRoot).Exec() Expect(filepath.Join(pullRoot, multi_arch.LayerName)).Should(BeAnExistingFile()) }) @@ -296,7 +311,7 @@ var _ = Describe("OCI spec 1.1 registry users:", func() { stateKeys := append(append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageReferrerConfigStateKeys[0]), foobar.ImageReferrersStateKeys...) src := RegistryRef(ZOTHost, ArtifactRepo, foobar.SignatureImageReferrer.Digest.String()) dst := RegistryRef(FallbackHost, repo, "") - ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() + ORAS("cp", "-r", src, dst).MatchStatus(stateKeys, true, len(stateKeys)).Exec() CompareRef(src, RegistryRef(FallbackHost, repo, foobar.SignatureImageReferrer.Digest.String())) ORAS("discover", "-o", "tree", RegistryRef(FallbackHost, repo, foobar.Digest)). WithDescription("discover referrer via subject").MatchKeyWords(foobar.SignatureImageReferrer.Digest.String(), foobar.SBOMImageReferrer.Digest.String()).Exec() @@ -310,7 +325,7 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { configName := "test.config" tempDir := PrepareTempFiles() stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(configName)) - ORAS("pull", RegistryRef(FallbackHost, ArtifactRepo, foobar.Tag), "-v", "--config", configName, "-o", pullRoot). + ORAS("pull", RegistryRef(FallbackHost, ArtifactRepo, foobar.Tag), "--config", configName, "-o", pullRoot). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(tempDir).Exec() // check config @@ -326,7 +341,7 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { WithWorkDir(tempDir).Exec() } - ORAS("pull", RegistryRef(FallbackHost, ArtifactRepo, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files"). + ORAS("pull", RegistryRef(FallbackHost, ArtifactRepo, foobar.Tag), "-o", pullRoot, "--keep-old-files"). ExpectFailure(). WithDescription("fail if overwrite old files are disabled") }) @@ -338,7 +353,7 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { foobar.ManifestStateKey), foobar.ImageReferrersStateKeys..., ) - ORAS("pull", RegistryRef(FallbackHost, ArtifactRepo, foobar.SignatureImageReferrer.Digest.String()), "-v", "--include-subject"). + ORAS("pull", RegistryRef(FallbackHost, ArtifactRepo, foobar.SignatureImageReferrer.Digest.String()), "--include-subject"). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(tempDir).Exec() }) @@ -353,7 +368,7 @@ var _ = Describe("OCI image layout users:", func() { pullRoot := "pulled" root := PrepareTempOCI(ImageRepo) stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(configName)) - ORAS("pull", Flags.Layout, LayoutRef(root, foobar.Tag), "-v", "--config", configName, "-o", pullRoot). + ORAS("pull", Flags.Layout, LayoutRef(root, foobar.Tag), "--config", configName, "-o", pullRoot). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(root).Exec() // check config @@ -369,7 +384,7 @@ var _ = Describe("OCI image layout users:", func() { WithWorkDir(root).Exec() } - ORAS("pull", Flags.Layout, LayoutRef(root, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files"). + ORAS("pull", Flags.Layout, LayoutRef(root, foobar.Tag), "-o", pullRoot, "--keep-old-files"). ExpectFailure(). WithDescription("fail if overwrite old files are disabled") }) @@ -378,7 +393,7 @@ var _ = Describe("OCI image layout users:", func() { pullRoot := "pulled" root := PrepareTempOCI(ImageRepo) stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey) - ORAS("pull", Flags.Layout, LayoutRef(root, foobar.Tag), "-v", "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot). + ORAS("pull", Flags.Layout, LayoutRef(root, foobar.Tag), "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(root).Exec() // check config @@ -398,14 +413,14 @@ var _ = Describe("OCI image layout users:", func() { foobar.ManifestStateKey), foobar.ImageReferrersStateKeys..., ) - ORAS("pull", Flags.Layout, LayoutRef(root, foobar.SignatureImageReferrer.Digest.String()), "-v", "--include-subject"). + ORAS("pull", Flags.Layout, LayoutRef(root, foobar.SignatureImageReferrer.Digest.String()), "--include-subject"). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(root).Exec() }) It("should pull specific platform", func() { root := PrepareTempOCI(ImageRepo) - ORAS("pull", Flags.Layout, LayoutRef(root, multi_arch.Tag), "--platform", "linux/amd64", "-v", "-o", root). + ORAS("pull", Flags.Layout, LayoutRef(root, multi_arch.Tag), "--platform", "linux/amd64", "-o", root). MatchStatus(multi_arch.LinuxAMD64StateKeys, true, len(multi_arch.LinuxAMD64StateKeys)).Exec() }) }) @@ -417,7 +432,7 @@ var _ = Describe("OCI image spec v1.1.0-rc2 artifact users:", func() { configName := "test.config" tempDir := PrepareTempFiles() stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(configName)) - ORAS("pull", RegistryRef(Host, ImageRepo, foobar.Tag), "-v", "--config", configName, "-o", pullRoot). + ORAS("pull", RegistryRef(Host, ImageRepo, foobar.Tag), "--config", configName, "-o", pullRoot). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(tempDir).Exec() // check config @@ -433,7 +448,7 @@ var _ = Describe("OCI image spec v1.1.0-rc2 artifact users:", func() { WithWorkDir(tempDir).Exec() } - ORAS("pull", RegistryRef(Host, ImageRepo, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files"). + ORAS("pull", RegistryRef(Host, ImageRepo, foobar.Tag), "-o", pullRoot, "--keep-old-files"). ExpectFailure(). WithDescription("fail if overwrite old files are disabled") }) @@ -445,7 +460,7 @@ var _ = Describe("OCI image spec v1.1.0-rc2 artifact users:", func() { foobar.ManifestStateKey), foobar.ArtifactReferrerStateKeys..., ) - ORAS("pull", RegistryRef(Host, ArtifactRepo, foobar.SignatureArtifactReferrer.Digest.String()), "-v", "--include-subject"). + ORAS("pull", RegistryRef(Host, ArtifactRepo, foobar.SignatureArtifactReferrer.Digest.String()), "--include-subject"). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(tempDir).Exec() }) diff --git a/test/e2e/suite/command/push.go b/test/e2e/suite/command/push.go index 339aab025..62a1ea8b7 100644 --- a/test/e2e/suite/command/push.go +++ b/test/e2e/suite/command/push.go @@ -45,6 +45,26 @@ var _ = Describe("ORAS beginners:", func() { MatchDefaultFlagValue("format", "text", "push") }) + It("should not show --verbose in help doc", func() { + out := ORAS("push", "--help").MatchKeyWords(ExampleDesc).Exec().Out + gomega.Expect(out).ShouldNot(gbytes.Say("--verbose")) + }) + + It("should show deprecation message for --verbose", func() { + repo := pushTestRepo("test-verbose") + tag := "e2e" + tempDir := PrepareTempFiles() + stateKeys := []match.StateKey{ + artifact.DefaultConfigStateKey, + } + + ORAS("push", RegistryRef(ZOTHost, repo, tag), "--verbose"). + WithWorkDir(tempDir). + MatchErrKeyWords("Flag --verbose has been deprecated"). + MatchStatus(stateKeys, true, len(stateKeys)). + Exec() + }) + It("should fail and show detailed error description if no argument provided", func() { err := ORAS("push").ExpectFailure().Exec().Err gomega.Expect(err).Should(gbytes.Say("Error")) @@ -143,7 +163,7 @@ var _ = Describe("Remote registry users:", func() { tempDir := PrepareTempFiles() ref := RegistryRef(ZOTHost, repo, tag) - ORAS("push", ref, foobar.FileBarName, "-v"). + ORAS("push", ref, foobar.FileBarName). MatchStatus(statusKeys, true, len(statusKeys)). WithWorkDir(tempDir).Exec() @@ -159,7 +179,7 @@ var _ = Describe("Remote registry users:", func() { ref := RegistryRef(ZOTHost, repo, tag) absBarName := filepath.Join(PrepareTempFiles(), foobar.FileBarName) - ORAS("push", ref, absBarName, "-v", "--disable-path-validation"). + ORAS("push", ref, absBarName, "--disable-path-validation"). Exec() // validate @@ -181,7 +201,7 @@ var _ = Describe("Remote registry users:", func() { ref := RegistryRef(ZOTHost, repo, tag) absBarName := filepath.Join(PrepareTempFiles(), foobar.FileBarName) // test - ORAS("push", ref, absBarName, "-v"). + ORAS("push", ref, absBarName). MatchErrKeyWords("--disable-path-validation"). ExpectFailure(). Exec() @@ -192,7 +212,7 @@ var _ = Describe("Remote registry users:", func() { tempDir := PrepareTempFiles() extraTag := "2e2" - ORAS("push", fmt.Sprintf("%s,%s", RegistryRef(ZOTHost, repo, tag), extraTag), foobar.FileBarName, "-v", "--format", "go-template={{range .referenceAsTags}}{{println .}}{{end}}"). + ORAS("push", fmt.Sprintf("%s,%s", RegistryRef(ZOTHost, repo, tag), extraTag), foobar.FileBarName, "--format", "go-template={{range .referenceAsTags}}{{println .}}{{end}}"). MatchContent(fmt.Sprintf("%s\n%s\n", RegistryRef(ZOTHost, repo, extraTag), RegistryRef(ZOTHost, repo, tag))). WithWorkDir(tempDir).Exec() @@ -212,7 +232,7 @@ var _ = Describe("Remote registry users:", func() { tempDir := PrepareTempFiles() extraTag := "2e2" - out := ORAS("push", fmt.Sprintf("%s,%s", RegistryRef(ZOTHost, repo, tag), extraTag), foobar.FileBarName, "-v", "--format", "json"). + out := ORAS("push", fmt.Sprintf("%s,%s", RegistryRef(ZOTHost, repo, tag), extraTag), foobar.FileBarName, "--format", "json"). WithWorkDir(tempDir). Exec().Out.Contents() Expect(json.Unmarshal(out, &struct{}{})).ShouldNot(HaveOccurred()) @@ -222,7 +242,7 @@ var _ = Describe("Remote registry users:", func() { repo := pushTestRepo("layer-mediatype") layerType := "layer/type" tempDir := PrepareTempFiles() - ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName+":"+layerType, "-v"). + ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName+":"+layerType). MatchStatus(statusKeys, true, len(statusKeys)). WithWorkDir(tempDir).Exec() // validate @@ -237,7 +257,7 @@ var _ = Describe("Remote registry users:", func() { layerType := "layer/type" tempDir := PrepareTempFiles() exportPath := "packed.json" - ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName+":"+layerType, "-v", "--export-manifest", exportPath). + ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName+":"+layerType, "--export-manifest", exportPath). MatchStatus(statusKeys, true, len(statusKeys)). WithWorkDir(tempDir).Exec() // validate @@ -249,7 +269,7 @@ var _ = Describe("Remote registry users:", func() { repo := pushTestRepo("config") tempDir := PrepareTempFiles() - ORAS("push", RegistryRef(ZOTHost, repo, tag), "--config", foobar.FileConfigName, foobar.FileBarName, "-v"). + ORAS("push", RegistryRef(ZOTHost, repo, tag), "--config", foobar.FileConfigName, foobar.FileBarName). MatchStatus([]match.StateKey{ foobar.FileConfigStateKey, foobar.FileBarStateKey, @@ -271,7 +291,7 @@ var _ = Describe("Remote registry users:", func() { configType := "my/config/type" tempDir := PrepareTempFiles() - ORAS("push", RegistryRef(ZOTHost, repo, tag), "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType), foobar.FileBarName, "-v"). + ORAS("push", RegistryRef(ZOTHost, repo, tag), "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType), foobar.FileBarName). MatchStatus([]match.StateKey{ {Digest: foobar.FileConfigStateKey.Digest, Name: configType}, foobar.FileBarStateKey, @@ -294,7 +314,7 @@ var _ = Describe("Remote registry users:", func() { configType := "config/type" tempDir := PrepareTempFiles() - ORAS("push", RegistryRef(ZOTHost, repo, tag), "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType), foobar.FileBarName, "-v"). + ORAS("push", RegistryRef(ZOTHost, repo, tag), "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType), foobar.FileBarName). MatchStatus([]match.StateKey{ {Digest: foobar.FileConfigStateKey.Digest, Name: configType}, foobar.FileBarStateKey, @@ -317,7 +337,7 @@ var _ = Describe("Remote registry users:", func() { value := "image-anno-value" tempDir := PrepareTempFiles() // test - ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "-v", "--annotation", fmt.Sprintf("%s=%s", key, value)). + ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "--annotation", fmt.Sprintf("%s=%s", key, value)). MatchStatus(statusKeys, true, len(statusKeys)). WithWorkDir(tempDir).Exec() // validate @@ -331,7 +351,7 @@ var _ = Describe("Remote registry users:", func() { repo := pushTestRepo("file-annotation") tempDir := PrepareTempFiles() - ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "-v", "--annotation-file", "foobar/annotation.json", "--config", foobar.FileConfigName). + ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "--annotation-file", "foobar/annotation.json", "--config", foobar.FileConfigName). MatchStatus(statusKeys, true, 1). WithWorkDir(tempDir).Exec() @@ -356,7 +376,7 @@ var _ = Describe("Remote registry users:", func() { annotationValue := "value" // test - ORAS("push", RegistryRef(ZOTHost, repo, tag), "-a", fmt.Sprintf("%s=%s", annotationKey, annotationValue), "-v", "--artifact-type", artifactType). + ORAS("push", RegistryRef(ZOTHost, repo, tag), "-a", fmt.Sprintf("%s=%s", annotationKey, annotationValue), "--artifact-type", artifactType). MatchStatus([]match.StateKey{artifact.DefaultConfigStateKey}, true, 1). WithWorkDir(tempDir).Exec() @@ -414,7 +434,7 @@ var _ = Describe("Remote registry users:", func() { repo := pushTestRepo("artifact-with-blob") tempDir := PrepareTempFiles() - ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "-v"). + ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName). MatchStatus([]match.StateKey{foobar.FileBarStateKey, artifact.DefaultConfigStateKey}, true, 2). WithWorkDir(tempDir).Exec() @@ -431,7 +451,7 @@ var _ = Describe("Remote registry users:", func() { repo := pushTestRepo("print-artifact-type-v1-1") tempDir := PrepareTempFiles() - ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "-v", "--image-spec", "v1.1"). + ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "--image-spec", "v1.1"). MatchKeyWords("ArtifactType: ", "application/vnd.unknown.artifact.v1"). WithWorkDir(tempDir).Exec() }) @@ -441,7 +461,7 @@ var _ = Describe("Remote registry users:", func() { configType := "config/type" tempDir := PrepareTempFiles() - ORAS("push", RegistryRef(ZOTHost, repo, tag), "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType), foobar.FileBarName, "-v", "--image-spec", "v1.0"). + ORAS("push", RegistryRef(ZOTHost, repo, tag), "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType), foobar.FileBarName, "--image-spec", "v1.0"). MatchKeyWords("ArtifactType: ", configType). WithWorkDir(tempDir).Exec() }) @@ -450,7 +470,7 @@ var _ = Describe("Remote registry users:", func() { repo := pushTestRepo("v1.1-artifact") tempDir := PrepareTempFiles() - ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "-v", "--image-spec", "v1.1"). + ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "--image-spec", "v1.1"). MatchStatus([]match.StateKey{foobar.FileBarStateKey, artifact.DefaultConfigStateKey}, true, 2). WithWorkDir(tempDir).Exec() @@ -468,7 +488,7 @@ var _ = Describe("Remote registry users:", func() { tempDir := PrepareTempFiles() configType := "test/config+json" - ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType), "-v"). + ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType)). MatchStatus([]match.StateKey{ foobar.FileBarStateKey, {Digest: foobar.FileConfigStateKey.Digest, Name: configType}, @@ -491,7 +511,7 @@ var _ = Describe("Remote registry users:", func() { artifactType := "test/artifact+json" configType := "test/config+json" - ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "--artifact-type", artifactType, "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType), "-v"). + ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "--artifact-type", artifactType, "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType)). MatchStatus([]match.StateKey{ foobar.FileBarStateKey, {Digest: foobar.FileConfigStateKey.Digest, Name: configType}, @@ -522,7 +542,7 @@ var _ = Describe("OCI image layout users:", func() { tempDir := PrepareTempFiles() ref := LayoutRef(tempDir, tag) // test - ORAS("push", Flags.Layout, ref, foobar.FileBarName, "-v"). + ORAS("push", Flags.Layout, ref, foobar.FileBarName). MatchStatus(statusKeys, true, len(statusKeys)). WithWorkDir(tempDir).Exec() // validate @@ -537,7 +557,7 @@ var _ = Describe("OCI image layout users:", func() { ref := LayoutRef(tempDir, tag) extraTag := "2e2" - ORAS("push", Flags.Layout, fmt.Sprintf("%s,%s", ref, extraTag), foobar.FileBarName, "-v"). + ORAS("push", Flags.Layout, fmt.Sprintf("%s,%s", ref, extraTag), foobar.FileBarName). MatchStatus(statusKeys, true, len(statusKeys)). WithWorkDir(tempDir).Exec() @@ -556,7 +576,7 @@ var _ = Describe("OCI image layout users:", func() { layerType := "layer.type" tempDir := PrepareTempFiles() ref := LayoutRef(tempDir, tag) - ORAS("push", Flags.Layout, ref, foobar.FileBarName+":"+layerType, "-v"). + ORAS("push", Flags.Layout, ref, foobar.FileBarName+":"+layerType). MatchStatus(statusKeys, true, len(statusKeys)). WithWorkDir(tempDir).Exec() // validate @@ -571,7 +591,7 @@ var _ = Describe("OCI image layout users:", func() { layerType := "layer.type" exportPath := "packed.json" ref := LayoutRef(tempDir, tag) - ORAS("push", ref, Flags.Layout, foobar.FileBarName+":"+layerType, "-v", "--export-manifest", exportPath). + ORAS("push", ref, Flags.Layout, foobar.FileBarName+":"+layerType, "--export-manifest", exportPath). MatchStatus(statusKeys, true, len(statusKeys)). WithWorkDir(tempDir).Exec() // validate @@ -582,7 +602,7 @@ var _ = Describe("OCI image layout users:", func() { It("should push files with customized config file", func() { tempDir := PrepareTempFiles() ref := LayoutRef(tempDir, tag) - ORAS("push", Flags.Layout, ref, "--config", foobar.FileConfigName, foobar.FileBarName, "-v"). + ORAS("push", Flags.Layout, ref, "--config", foobar.FileConfigName, foobar.FileBarName). MatchStatus([]match.StateKey{ foobar.FileConfigStateKey, foobar.FileBarStateKey, @@ -603,7 +623,7 @@ var _ = Describe("OCI image layout users:", func() { configType := "config/type" tempDir := PrepareTempFiles() ref := LayoutRef(tempDir, tag) - ORAS("push", Flags.Layout, ref, "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType), foobar.FileBarName, "-v"). + ORAS("push", Flags.Layout, ref, "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType), foobar.FileBarName). MatchStatus([]match.StateKey{ {Digest: foobar.FileConfigStateKey.Digest, Name: configType}, foobar.FileBarStateKey, @@ -623,7 +643,7 @@ var _ = Describe("OCI image layout users:", func() { It("should push files with platform", func() { tempDir := PrepareTempFiles() ref := LayoutRef(tempDir, tag) - ORAS("push", Flags.Layout, ref, "--artifact-platform", "darwin/arm64", foobar.FileBarName, "-v"). + ORAS("push", Flags.Layout, ref, "--artifact-platform", "darwin/arm64", foobar.FileBarName). MatchStatus([]match.StateKey{ foobar.PlatformConfigStateKey, foobar.FileBarStateKey, @@ -647,7 +667,7 @@ var _ = Describe("OCI image layout users:", func() { It("should fail to customize config mediaType when baking config blob with platform for v1.0", func() { tempDir := PrepareTempFiles() ref := LayoutRef(tempDir, tag) - ORAS("push", Flags.Layout, ref, "--image-spec", "v1.0", "--artifact-type", "test/artifact+json", "--artifact-platform", "darwin/arm64", foobar.FileBarName, "-v"). + ORAS("push", Flags.Layout, ref, "--image-spec", "v1.0", "--artifact-type", "test/artifact+json", "--artifact-platform", "darwin/arm64", foobar.FileBarName). ExpectFailure(). Exec() }) @@ -655,7 +675,7 @@ var _ = Describe("OCI image layout users:", func() { It("should push files with platform with no artifactType for v1.0", func() { tempDir := PrepareTempFiles() ref := LayoutRef(tempDir, tag) - ORAS("push", Flags.Layout, ref, "--image-spec", "v1.0", "--artifact-platform", "darwin/arm64", foobar.FileBarName, "-v"). + ORAS("push", Flags.Layout, ref, "--image-spec", "v1.0", "--artifact-platform", "darwin/arm64", foobar.FileBarName). MatchStatus([]match.StateKey{ foobar.PlatformV1DEfaultConfigStateKey, foobar.FileBarStateKey, @@ -678,7 +698,7 @@ var _ = Describe("OCI image layout users:", func() { key := "image-anno-key" value := "image-anno-value" // test - ORAS("push", Flags.Layout, ref, foobar.FileBarName, "-v", "--annotation", fmt.Sprintf("%s=%s", key, value)). + ORAS("push", Flags.Layout, ref, foobar.FileBarName, "--annotation", fmt.Sprintf("%s=%s", key, value)). MatchStatus(statusKeys, true, len(statusKeys)). WithWorkDir(tempDir).Exec() // validate @@ -692,7 +712,7 @@ var _ = Describe("OCI image layout users:", func() { tempDir := PrepareTempFiles() ref := LayoutRef(tempDir, tag) // test - ORAS("push", ref, Flags.Layout, foobar.FileBarName, "-v", "--annotation-file", "foobar/annotation.json", "--config", foobar.FileConfigName). + ORAS("push", ref, Flags.Layout, foobar.FileBarName, "--annotation-file", "foobar/annotation.json", "--config", foobar.FileConfigName). MatchStatus(statusKeys, true, 1). WithWorkDir(tempDir).Exec() diff --git a/test/e2e/suite/command/repo.go b/test/e2e/suite/command/repo.go index 8bc924498..46f2a2f64 100644 --- a/test/e2e/suite/command/repo.go +++ b/test/e2e/suite/command/repo.go @@ -134,12 +134,12 @@ var _ = Describe("1.1 registry users:", func() { WithDescription("prepare: copy tag with different digest"). Exec() // test - viaTag := ORAS("repo", "tags", "-v", RegistryRef(ZOTHost, repo, foobar.Tag)). + viaTag := ORAS("repo", "tags", RegistryRef(ZOTHost, repo, foobar.Tag)). MatchKeyWords(tags...). MatchErrKeyWords(feature.Experimental.Mark, foobar.Digest).Exec().Out Expect(viaTag).ShouldNot(gbytes.Say(multi_arch.Tag)) - viaDigest := ORAS("repo", "tags", "-v", RegistryRef(ZOTHost, repo, foobar.Digest)). + viaDigest := ORAS("repo", "tags", RegistryRef(ZOTHost, repo, foobar.Digest)). MatchKeyWords(tags...). MatchErrKeyWords(feature.Experimental.Mark, foobar.Digest).Exec().Out Expect(viaDigest).ShouldNot(gbytes.Say(multi_arch.Tag)) @@ -189,12 +189,12 @@ var _ = Describe("OCI image layout users:", func() { tags := []string{foobar.Tag, "bax", "bay", "baz"} root := prepare(ImageRepo, foobar.Tag, tags...) // test - viaTag := ORAS("repo", "tags", "-v", LayoutRef(root, foobar.Tag), Flags.Layout). + viaTag := ORAS("repo", "tags", LayoutRef(root, foobar.Tag), Flags.Layout). WithDescription("via tag"). MatchKeyWords(tags...). MatchErrKeyWords(feature.Experimental.Mark, foobar.Digest).Exec().Out Expect(viaTag).ShouldNot(gbytes.Say(multi_arch.Tag)) - viaDigest := ORAS("repo", "tags", "-v", LayoutRef(root, foobar.Digest), Flags.Layout). + viaDigest := ORAS("repo", "tags", LayoutRef(root, foobar.Digest), Flags.Layout). WithDescription("via digest"). MatchKeyWords(tags...). MatchErrKeyWords(feature.Experimental.Mark, foobar.Digest).Exec().Out diff --git a/test/e2e/suite/command/resolve_host.go b/test/e2e/suite/command/resolve_host.go index a6e95bd47..724705b05 100644 --- a/test/e2e/suite/command/resolve_host.go +++ b/test/e2e/suite/command/resolve_host.go @@ -126,7 +126,7 @@ var _ = Describe("1.1 registry users:", func() { It("should copy an image with source resolve DNS rules", func() { repo := testRepo("cp/from") dst := RegistryRef(Host, repo, "copied") - ORAS(append([]string{"cp", RegistryRef(mockedHost, ImageRepo, foobar.Tag), dst, "-v"}, from...)...). + ORAS(append([]string{"cp", RegistryRef(mockedHost, ImageRepo, foobar.Tag), dst}, from...)...). MatchStatus(foobarStates, true, len(foobarStates)). Exec() CompareRef(RegistryRef(Host, ImageRepo, foobar.Tag), dst) @@ -136,7 +136,7 @@ var _ = Describe("1.1 registry users:", func() { src := RegistryRef(Host, ImageRepo, foobar.Tag) repo := testRepo("cp/to") tag := "copied" - ORAS(append([]string{"cp", src, RegistryRef(mockedHost, repo, tag), "-v"}, to...)...). + ORAS(append([]string{"cp", src, RegistryRef(mockedHost, repo, tag)}, to...)...). MatchStatus(foobarStates, true, len(foobarStates)). Exec() CompareRef(src, RegistryRef(Host, repo, tag)) @@ -147,7 +147,7 @@ var _ = Describe("1.1 registry users:", func() { repo := testRepo("cp/base") tag := "copied" flags := append(to[2:], "--resolve", unary[1]) //hack to chop the destination flags off - ORAS(append([]string{"cp", src, RegistryRef(mockedHost, repo, tag), "-v"}, flags...)...). + ORAS(append([]string{"cp", src, RegistryRef(mockedHost, repo, tag)}, flags...)...). MatchStatus(foobarStates, true, len(foobarStates)). Exec() CompareRef(src, RegistryRef(Host, repo, tag)) @@ -157,7 +157,7 @@ var _ = Describe("1.1 registry users:", func() { repo := testRepo("cp/override") tag := "copied" flags := append(append(to, from...), "--resolve", mockedHost+":80:1.1.1.1:5000") - ORAS(append([]string{"cp", RegistryRef(mockedHost, ImageRepo, foobar.Tag), RegistryRef(mockedHost, repo, tag), "-v"}, flags...)...). + ORAS(append([]string{"cp", RegistryRef(mockedHost, ImageRepo, foobar.Tag), RegistryRef(mockedHost, repo, tag)}, flags...)...). MatchStatus(foobarStates, true, len(foobarStates)). Exec() CompareRef(RegistryRef(Host, ImageRepo, foobar.Tag), RegistryRef(Host, repo, tag)) @@ -215,7 +215,7 @@ var _ = Describe("1.1 registry users:", func() { tempDir := PrepareTempFiles() stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(configName)) // test - ORAS(append([]string{"pull", RegistryRef(mockedHost, ImageRepo, foobar.Tag), "-v", "--config", configName, "-o", pullRoot}, unary...)...). + ORAS(append([]string{"pull", RegistryRef(mockedHost, ImageRepo, foobar.Tag), "--config", configName, "-o", pullRoot}, unary...)...). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(tempDir).Exec() // validate config and layers @@ -235,7 +235,7 @@ var _ = Describe("1.1 registry users:", func() { It("should push files without customized media types", func() { repo := testRepo("push") tempDir := PrepareTempFiles() - ORAS(append([]string{"push", RegistryRef(mockedHost, repo, foobar.Tag), "-v"}, append(foobar.FileLayerNames, unary...)...)...). + ORAS(append([]string{"push", RegistryRef(mockedHost, repo, foobar.Tag)}, append(foobar.FileLayerNames, unary...)...)...). MatchStatus(foobar.FileStateKeys, true, len(foobar.FileStateKeys)). WithWorkDir(tempDir).Exec() }) diff --git a/test/e2e/suite/scenario/oci_artifact.go b/test/e2e/suite/scenario/oci_artifact.go index ee726f8f4..5b1a4e521 100644 --- a/test/e2e/suite/scenario/oci_artifact.go +++ b/test/e2e/suite/scenario/oci_artifact.go @@ -37,7 +37,7 @@ var _ = Describe("OCI artifact users:", Ordered, func() { pulledManifest := "packed.json" pullRoot := "pulled" It("should push and pull an artifact", func() { - ORAS("push", RegistryRef(ZOTHost, repo, tag), "--artifact-type", "test/artifact", foobar.FileLayerNames[0], foobar.FileLayerNames[1], foobar.FileLayerNames[2], "-v", "--export-manifest", pulledManifest). + ORAS("push", RegistryRef(ZOTHost, repo, tag), "--artifact-type", "test/artifact", foobar.FileLayerNames[0], foobar.FileLayerNames[1], foobar.FileLayerNames[2], "--export-manifest", pulledManifest). MatchStatus(foobar.FileStateKeys, true, 3). WithWorkDir(tempDir). WithDescription("push with manifest exported").Exec() @@ -45,7 +45,7 @@ var _ = Describe("OCI artifact users:", Ordered, func() { fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, tag)).Exec() MatchFile(filepath.Join(tempDir, pulledManifest), string(fetched.Out.Contents()), DefaultTimeout) - ORAS("pull", RegistryRef(ZOTHost, repo, tag), "-v", "-o", pullRoot). + ORAS("pull", RegistryRef(ZOTHost, repo, tag), "-o", pullRoot). MatchStatus(foobar.FileStateKeys, true, 3). WithWorkDir(tempDir). WithDescription("pull artFiles with config").Exec() @@ -59,7 +59,7 @@ var _ = Describe("OCI artifact users:", Ordered, func() { It("should attach and pull an artifact", func() { subject := RegistryRef(ZOTHost, repo, tag) - ORAS("attach", subject, "--artifact-type", "test/artifact1", fmt.Sprint(foobar.AttachFileName, ":", foobar.AttachFileMedia), "-v", "--export-manifest", pulledManifest). + ORAS("attach", subject, "--artifact-type", "test/artifact1", fmt.Sprint(foobar.AttachFileName, ":", foobar.AttachFileMedia), "--export-manifest", pulledManifest). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, true, 1). WithWorkDir(tempDir). WithDescription("attach with manifest exported").Exec() @@ -68,7 +68,7 @@ var _ = Describe("OCI artifact users:", Ordered, func() { fetched := ORAS("manifest", "fetch", ref).MatchKeyWords(foobar.AttachFileMedia).Exec() MatchFile(filepath.Join(tempDir, pulledManifest), string(fetched.Out.Contents()), DefaultTimeout) - ORAS("pull", ref, "-v", "-o", pullRoot). + ORAS("pull", ref, "-o", pullRoot). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, true, 1). WithWorkDir(tempDir). WithDescription("pull attached artifact").Exec() @@ -76,7 +76,7 @@ var _ = Describe("OCI artifact users:", Ordered, func() { WithWorkDir(tempDir). WithDescription("download identical file " + foobar.AttachFileName).Exec() - ORAS("attach", subject, "--artifact-type", "test/artifact2", fmt.Sprint(foobar.AttachFileName, ":", foobar.AttachFileMedia), "-v", "--export-manifest", pulledManifest). + ORAS("attach", subject, "--artifact-type", "test/artifact2", fmt.Sprint(foobar.AttachFileName, ":", foobar.AttachFileMedia), "--export-manifest", pulledManifest). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, true, 1). WithWorkDir(tempDir). WithDescription("attach again with manifest exported").Exec() @@ -85,7 +85,7 @@ var _ = Describe("OCI artifact users:", Ordered, func() { fetched = ORAS("manifest", "fetch", ref).MatchKeyWords(foobar.AttachFileMedia).Exec() MatchFile(filepath.Join(tempDir, pulledManifest), string(fetched.Out.Contents()), DefaultTimeout) - ORAS("pull", ref, "-v", "-o", pullRoot, "--include-subject"). + ORAS("pull", ref, "-o", pullRoot, "--include-subject"). MatchStatus(append(foobar.FileStateKeys, foobar.AttachFileStateKey), true, 4). WithWorkDir(tempDir). WithDescription("pull attached artifact and subject").Exec() diff --git a/test/e2e/suite/scenario/oci_image.go b/test/e2e/suite/scenario/oci_image.go index fed95c281..b60714dd8 100644 --- a/test/e2e/suite/scenario/oci_image.go +++ b/test/e2e/suite/scenario/oci_image.go @@ -36,7 +36,7 @@ var _ = Describe("OCI image user:", Ordered, func() { It("should push and pull an image", func() { manifestName := "packed.json" - ORAS("push", RegistryRef(Host, repo, tag), "--config", files[0], files[1], files[2], files[3], "-v", "--export-manifest", manifestName). + ORAS("push", RegistryRef(Host, repo, tag), "--config", files[0], files[1], files[2], files[3], "--export-manifest", manifestName). MatchStatus(statusKeys, true, 4). WithWorkDir(tempDir). WithDescription("push files with manifest exported").Exec() @@ -46,7 +46,7 @@ var _ = Describe("OCI image user:", Ordered, func() { MatchFile(filepath.Join(tempDir, manifestName), string(fetched), DefaultTimeout) pullRoot := "pulled" - ORAS("pull", RegistryRef(Host, repo, tag), "-v", "--config", files[0], "-o", pullRoot). + ORAS("pull", RegistryRef(Host, repo, tag), "--config", files[0], "-o", pullRoot). MatchStatus(statusKeys, true, 3). WithWorkDir(tempDir). WithDescription("pull files with config").Exec()