Skip to content

Commit 86287e0

Browse files
fix: bring back --verbose flag (#1660)
Signed-off-by: Xiaoxuan Wang <[email protected]>
1 parent 4a8f5e5 commit 86287e0

File tree

17 files changed

+81
-1
lines changed

17 files changed

+81
-1
lines changed

cmd/oras/internal/option/verbose.go

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
Copyright The ORAS Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
package option
17+
18+
import "github.com/spf13/pflag"
19+
20+
// AddDeprecatedVerboseFlag adds the deprecated verbose flag to a command
21+
func AddDeprecatedVerboseFlag(flags *pflag.FlagSet) {
22+
// ignoring the variable of the verbose flag, since we will not use it
23+
_ = flags.BoolP("verbose", "v", false, "verbose output")
24+
_ = flags.MarkDeprecated("verbose", "and will be removed in a future release.")
25+
}

cmd/oras/root/blob/delete.go

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Example - Delete a blob and print its descriptor:
6969
},
7070
}
7171

72+
option.AddDeprecatedVerboseFlag(cmd.Flags())
7273
option.ApplyFlags(&opts, cmd.Flags())
7374
return oerrors.Command(cmd, &opts.Target)
7475
}

cmd/oras/root/blob/fetch.go

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Example - Fetch and print a blob from OCI image layout archive file 'layout.tar'
9292
}
9393

9494
cmd.Flags().StringVarP(&opts.outputPath, "output", "o", "", "output file `path`, use - for stdout")
95+
option.AddDeprecatedVerboseFlag(cmd.Flags())
9596
option.ApplyFlags(&opts, cmd.Flags())
9697
return oerrors.Command(cmd, &opts.Target)
9798
}

cmd/oras/root/login.go

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Example - Log in with username and password in an interactive terminal and no TL
7373
return runLogin(cmd, opts)
7474
},
7575
}
76+
option.AddDeprecatedVerboseFlag(cmd.Flags())
7677
option.ApplyFlags(&opts, cmd.Flags())
7778
return oerrors.Command(cmd, &opts.Remote)
7879
}

cmd/oras/root/manifest/delete.go

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Example - Delete a manifest by digest 'sha256:99e4703fbf30916f549cd6bfa9cdbab614
7474

7575
opts.EnableDistributionSpecFlag()
7676
option.ApplyFlags(&opts, cmd.Flags())
77+
option.AddDeprecatedVerboseFlag(cmd.Flags())
7778
return oerrors.Command(cmd, &opts.Target)
7879
}
7980

cmd/oras/root/manifest/fetch.go

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Example - Fetch raw manifest from an OCI layout archive file 'layout.tar':
106106
option.FormatTypeJSON.WithUsage("Print in prettified JSON format"),
107107
option.FormatTypeGoTemplate.WithUsage("Print using the given Go template"),
108108
)
109+
option.AddDeprecatedVerboseFlag(cmd.Flags())
109110
option.ApplyFlags(&opts, cmd.Flags())
110111
return oerrors.Command(cmd, &opts.Target)
111112
}

cmd/oras/root/manifest/fetch_config.go

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Example - Fetch and print the prettified descriptor of the config:
8484
}
8585

8686
cmd.Flags().StringVarP(&opts.outputPath, "output", "o", "", "file `path` to write the fetched config to, use - for stdout")
87+
option.AddDeprecatedVerboseFlag(cmd.Flags())
8788
option.ApplyFlags(&opts, cmd.Flags())
8889
return oerrors.Command(cmd, &opts.Target)
8990
}

cmd/oras/root/repo/ls.go

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Example - List the repositories under the registry that include values lexically
6767
}
6868

6969
cmd.Flags().StringVar(&opts.last, "last", "", "start after the repository specified by `last`")
70+
option.AddDeprecatedVerboseFlag(cmd.Flags())
7071
option.ApplyFlags(&opts, cmd.Flags())
7172
return oerrors.Command(cmd, &opts.Remote)
7273
}

cmd/oras/root/repo/tags.go

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Example - [Experimental] Show tags associated with a digest:
7575
}
7676
cmd.Flags().StringVar(&opts.last, "last", "", "start after the tag specified by `last`")
7777
cmd.Flags().BoolVar(&opts.excludeDigestTag, "exclude-digest-tags", false, "[Preview] exclude all digest-like tags such as 'sha256-aaaa...'")
78+
option.AddDeprecatedVerboseFlag(cmd.Flags())
7879
option.ApplyFlags(&opts, cmd.Flags())
7980
return oerrors.Command(cmd, &opts.Target)
8081
}

cmd/oras/root/resolve.go

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Example - Resolve digest of the target artifact:
5858
}
5959

6060
cmd.Flags().BoolVarP(&opts.fullRef, "full-reference", "l", false, "print the full artifact reference with digest")
61+
option.AddDeprecatedVerboseFlag(cmd.Flags())
6162
option.ApplyFlags(&opts, cmd.Flags())
6263
return oerrors.Command(cmd, &opts.Target)
6364
}

cmd/oras/root/tag.go

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Example - Tag the manifest 'v1.0.1' to 'v1.0.2' in an OCI image layout folder 'l
9696

9797
option.ApplyFlags(&opts, cmd.Flags())
9898
cmd.Flags().IntVarP(&opts.concurrency, "concurrency", "", 5, "concurrency level")
99+
option.AddDeprecatedVerboseFlag(cmd.Flags())
99100
return oerrors.Command(cmd, &opts.Target)
100101
}
101102

test/e2e/suite/auth/auth.go

+6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
. "github.com/onsi/gomega"
2626
"github.com/onsi/gomega/gbytes"
2727
"oras.land/oras-go/v2"
28+
"oras.land/oras/test/e2e/internal/testdata/feature"
2829
"oras.land/oras/test/e2e/internal/testdata/foobar"
2930
. "oras.land/oras/test/e2e/internal/utils"
3031
)
@@ -92,6 +93,11 @@ var _ = Describe("Common registry user", func() {
9293
MatchErrKeyWords("WARNING", "Using --password via the CLI is insecure", "Use --password-stdin").Exec()
9394
})
9495

96+
It("should show deprecation message when running with --verbose flag", func() {
97+
ORAS("login", ZOTHost, "-u", Username, "-p", Password, "--registry-config", filepath.Join(GinkgoT().TempDir(), tmpConfigName), "--verbose").
98+
MatchErrKeyWords(feature.DeprecationMessageVerboseFlag).Exec()
99+
})
100+
95101
It("should show detailed error description if no argument provided", func() {
96102
err := ORAS("login").ExpectFailure().Exec().Err
97103
Expect(err).Should(gbytes.Say("Error"))

test/e2e/suite/command/blob.go

+11
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,13 @@ var _ = Describe("1.1 registry users:", func() {
252252
MatchKeyWords("Missing", toDeleteRef).
253253
Exec()
254254
})
255+
256+
It("should show deprecation message when running with --verbose flag", func() {
257+
dstRepo := fmt.Sprintf(repoFmt, "delete", "blob-delete-verbose")
258+
CopyZOTRepo(BlobRepo, dstRepo)
259+
toDeleteRef := RegistryRef(ZOTHost, dstRepo, foobar.FooBlobDigest)
260+
ORAS("blob", "delete", toDeleteRef, "--verbose").MatchErrKeyWords(feature.DeprecationMessageVerboseFlag).Exec()
261+
})
255262
})
256263
When("running `blob push`", func() {
257264
It("should push a blob from a file and output the descriptor with specific media-type", func() {
@@ -288,6 +295,10 @@ var _ = Describe("1.1 registry users:", func() {
288295
ORAS("blob", "fetch", RegistryRef(ZOTHost, ImageRepo, foobar.FooBlobDigest), "--output", "-").
289296
MatchContent(foobar.FooBlobContent).Exec()
290297
})
298+
It("should show deprecation message when running with --verbose flag", func() {
299+
ORAS("blob", "fetch", RegistryRef(ZOTHost, ImageRepo, foobar.FooBlobDigest), "--descriptor", "--verbose").
300+
MatchErrKeyWords(feature.DeprecationMessageVerboseFlag).Exec()
301+
})
291302
It("should fetch blob content and output to a file", func() {
292303
tempDir := GinkgoT().TempDir()
293304
contentPath := filepath.Join(tempDir, "fetched")

test/e2e/suite/command/manifest.go

+16
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ var _ = Describe("ORAS beginners:", func() {
134134
MatchDefaultFlagValue("format", "text", "manifest", "fetch")
135135
})
136136

137+
It("should show deprecation message when running with --verbose flag", func() {
138+
ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "--verbose").MatchErrKeyWords(feature.DeprecationMessageVerboseFlag).Exec()
139+
})
140+
137141
It("should fail and show detailed error description if no argument provided", func() {
138142
err := ORAS("manifest", "fetch").ExpectFailure().Exec().Err
139143
gomega.Expect(err).Should(gbytes.Say("Error"))
@@ -447,6 +451,11 @@ var _ = Describe("1.1 registry users:", func() {
447451
MatchContent("{}").Exec()
448452
})
449453

454+
It("should show deprecation message when running with --verbose flag", func() {
455+
ORAS("manifest", "fetch-config", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "--verbose").
456+
MatchErrKeyWords(feature.DeprecationMessageVerboseFlag).Exec()
457+
})
458+
450459
It("should fetch a config descriptor via a tag", func() {
451460
ORAS("manifest", "fetch-config", "--descriptor", RegistryRef(ZOTHost, ImageRepo, foobar.Tag)).
452461
MatchContent(foobar.ImageConfigDesc).Exec()
@@ -486,6 +495,13 @@ var _ = Describe("1.1 registry users:", func() {
486495
validateTag(RegistryRef(ZOTHost, dstRepo, ""), tempTag, true)
487496
})
488497

498+
It("should show deprecation message when running with --verbose flag", func() {
499+
dstRepo := fmt.Sprintf(repoFmt, "delete", "verbose-flag")
500+
prepare(RegistryRef(ZOTHost, ImageRepo, foobar.Tag), RegistryRef(ZOTHost, dstRepo, tempTag))
501+
ORAS("manifest", "delete", RegistryRef(ZOTHost, dstRepo, tempTag), "--verbose").
502+
MatchErrKeyWords(feature.DeprecationMessageVerboseFlag).Exec()
503+
})
504+
489505
It("should do confirmed deletion via flag", func() {
490506
dstRepo := fmt.Sprintf(repoFmt, "delete", "confirm-flag")
491507
prepare(RegistryRef(ZOTHost, ImageRepo, foobar.Tag), RegistryRef(ZOTHost, dstRepo, tempTag))

test/e2e/suite/command/repo.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ var _ = Describe("1.1 registry users:", func() {
9393
It("should list repositories under provided namespace", func() {
9494
ORAS("repo", "ls", RegistryRef(ZOTHost, Namespace, "")).MatchKeyWords(ImageRepo[len(Namespace)+1:]).Exec()
9595
})
96+
It("should show deprecation message when running with --verbose flag", func() {
97+
ORAS("repository", "list", ZOTHost, "--verbose").MatchErrKeyWords(feature.DeprecationMessageVerboseFlag).Exec()
98+
})
9699

97100
It("should not list repositories without a fully matched namespace", func() {
98101
repo := "command-draft/images"
@@ -119,7 +122,9 @@ var _ = Describe("1.1 registry users:", func() {
119122
})
120123
It("should list tags via short command", func() {
121124
ORAS("repo", "tags", repoRef).MatchKeyWords(multi_arch.Tag, foobar.Tag).Exec()
122-
125+
})
126+
It("should show deprecation message when running with --verbose flag", func() {
127+
ORAS("repo", "tags", repoRef, "--verbose").MatchErrKeyWords(feature.DeprecationMessageVerboseFlag).Exec()
123128
})
124129

125130
It("Should list out tags associated to the provided reference", func() {

test/e2e/suite/command/resolve.go

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ var _ = Describe("Common registry user", func() {
7878
out := ORAS("digest", "-l", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag)).Exec().Out
7979
gomega.Expect(out).To(gbytes.Say(fmt.Sprintf("%s/%s@%s", ZOTHost, ImageRepo, multi_arch.Digest)))
8080
})
81+
It("should show deprecation message when running with --verbose flag", func() {
82+
ORAS("resolve", RegistryRef(ZOTHost, ImageRepo, multi_arch.Digest), "--verbose").MatchErrKeyWords(feature.DeprecationMessageVerboseFlag).Exec()
83+
})
8184
It("should resolve with a fully qualified reference for a platform", func() {
8285
out := ORAS("resolve", "--full-reference", "--platform", "linux/amd64", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag)).Exec().Out
8386
gomega.Expect(out).To(gbytes.Say(fmt.Sprintf("%s/%s@%s", ZOTHost, ImageRepo, multi_arch.LinuxAMD64.Digest)))

test/e2e/suite/command/tag.go

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
. "github.com/onsi/ginkgo/v2"
2525
"github.com/onsi/gomega"
2626
"github.com/onsi/gomega/gbytes"
27+
"oras.land/oras/test/e2e/internal/testdata/feature"
2728
"oras.land/oras/test/e2e/internal/testdata/foobar"
2829
"oras.land/oras/test/e2e/internal/testdata/multi_arch"
2930
. "oras.land/oras/test/e2e/internal/utils"
@@ -68,6 +69,9 @@ func tagAndValidate(reg string, repo string, tagOrDigest string, digestText stri
6869

6970
var _ = Describe("1.1 registry users:", func() {
7071
When("running `tag`", func() {
72+
It("should show deprecation message when running with --verbose flag", func() {
73+
ORAS("tag", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag), "latest", "--verbose").MatchErrKeyWords(feature.DeprecationMessageVerboseFlag).Exec()
74+
})
7175
It("should add a tag to an existent manifest when providing tag reference", func() {
7276
tagAndValidate(ZOTHost, ImageRepo, multi_arch.Tag, multi_arch.Digest, "tag-via-tag")
7377
})

0 commit comments

Comments
 (0)