diff --git a/cmd/oras/blob/cmd.go b/cmd/oras/blob/cmd.go index 1ad708677..440682fb3 100644 --- a/cmd/oras/blob/cmd.go +++ b/cmd/oras/blob/cmd.go @@ -22,7 +22,7 @@ import ( func Cmd() *cobra.Command { cmd := &cobra.Command{ Use: "blob [command]", - Short: "[Preview] Blob operations", + Short: "Blob operations", } cmd.AddCommand( diff --git a/cmd/oras/blob/delete.go b/cmd/oras/blob/delete.go index 3ce58df88..d0551a702 100644 --- a/cmd/oras/blob/delete.go +++ b/cmd/oras/blob/delete.go @@ -40,10 +40,8 @@ func deleteCmd() *cobra.Command { cmd := &cobra.Command{ Use: "delete [flags] @", Aliases: []string{"remove", "rm"}, - Short: "[Preview] Delete a blob from a remote registry", - Long: `[Preview] Delete a blob from a remote registry - -** This command is in preview and under development. ** + Short: "Delete a blob from a remote registry", + Long: `Delete a blob from a remote registry Example - Delete a blob: oras blob delete localhost:5000/hello@sha256:9a201d228ebd966211f7d1131be19f152be428bd373a92071c71d8deaf83b3e5 diff --git a/cmd/oras/blob/fetch.go b/cmd/oras/blob/fetch.go index ed2a7d18e..f5c9b05f4 100644 --- a/cmd/oras/blob/fetch.go +++ b/cmd/oras/blob/fetch.go @@ -44,10 +44,8 @@ func fetchCmd() *cobra.Command { var opts fetchBlobOptions cmd := &cobra.Command{ Use: "fetch [flags] {--output | --descriptor} @", - Short: "[Preview] Fetch a blob from a remote registry", - Long: `[Preview] Fetch a blob from a remote registry - -** This command is in preview and under development. ** + Short: "Fetch a blob from a remote registry", + Long: `Fetch a blob from a remote registry Example - Fetch a blob from registry and save it to a local file: oras blob fetch --output blob.tar.gz localhost:5000/hello@sha256:9a201d228ebd966211f7d1131be19f152be428bd373a92071c71d8deaf83b3e5 diff --git a/cmd/oras/blob/push.go b/cmd/oras/blob/push.go index 187ab82f4..35b6e1619 100644 --- a/cmd/oras/blob/push.go +++ b/cmd/oras/blob/push.go @@ -42,10 +42,8 @@ func pushCmd() *cobra.Command { var opts pushBlobOptions cmd := &cobra.Command{ Use: "push [flags] [@digest] ", - Short: "[Preview] Push a blob to a remote registry", - Long: `[Preview] Push a blob to a remote registry - -** This command is in preview and under development. ** + Short: "Push a blob to a remote registry", + Long: `Push a blob to a remote registry Example - Push blob 'hi.txt' to a registry: oras blob push localhost:5000/hello hi.txt diff --git a/cmd/oras/cp.go b/cmd/oras/cp.go index 606ecf5c2..6214a1415 100644 --- a/cmd/oras/cp.go +++ b/cmd/oras/cp.go @@ -45,10 +45,8 @@ func copyCmd() *cobra.Command { cmd := &cobra.Command{ Use: "cp [flags] {:|@} [:[,][...]]", Aliases: []string{"copy"}, - Short: "[Preview] Copy artifacts from one target to another", - Long: `[Preview] Copy artifacts from one target to another - -** This command is in preview and under development. ** + Short: "Copy artifacts from one target to another", + Long: `Copy artifacts from one target to another Example - Copy an artifact between registries: oras cp localhost:5000/net-monitor:v1 localhost:6000/net-monitor-copy:v1 @@ -90,7 +88,7 @@ Example - Copy an artifact with multiple tags with concurrency tuned: return runCopy(opts) }, } - cmd.Flags().BoolVarP(&opts.recursive, "recursive", "r", false, "recursively copy the artifact and its referrer artifacts") + 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") opts.EnableDistributionSpecFlag() option.ApplyFlags(&opts, cmd.Flags()) diff --git a/cmd/oras/internal/option/spec.go b/cmd/oras/internal/option/spec.go index e8338110d..9d994ff02 100644 --- a/cmd/oras/internal/option/spec.go +++ b/cmd/oras/internal/option/spec.go @@ -46,7 +46,7 @@ func (opts *ImageSpec) Parse() error { // ApplyFlags applies flags to a command flag set. func (opts *ImageSpec) ApplyFlags(fs *pflag.FlagSet) { - fs.StringVar(&opts.specFlag, "image-spec", "v1.1-image", "specify manifest type for building artifact. options: v1.1-image, v1.1-artifact") + fs.StringVar(&opts.specFlag, "image-spec", "v1.1-image", "[Experimental] specify manifest type for building artifact. options: v1.1-image, v1.1-artifact") } // distributionSpec option struct. @@ -79,5 +79,5 @@ func (opts *distributionSpec) Parse() error { // ApplyFlagsWithPrefix applies flags to a command flag set with a prefix string. func (opts *distributionSpec) ApplyFlagsWithPrefix(fs *pflag.FlagSet, prefix, description string) { flagPrefix, notePrefix := applyPrefix(prefix, description) - fs.StringVar(&opts.specFlag, flagPrefix+"distribution-spec", "", "set OCI distribution spec version and API option for "+notePrefix+"target. options: v1.1-referrers-api, v1.1-referrers-tag") + fs.StringVar(&opts.specFlag, flagPrefix+"distribution-spec", "", "[Preview] set OCI distribution spec version and API option for "+notePrefix+"target. options: v1.1-referrers-api, v1.1-referrers-tag") } diff --git a/cmd/oras/internal/option/target.go b/cmd/oras/internal/option/target.go index fef1ddeb5..9494e1789 100644 --- a/cmd/oras/internal/option/target.go +++ b/cmd/oras/internal/option/target.go @@ -72,7 +72,7 @@ func (opts *Target) AnnotatedReference() string { // the full form is not implemented until a new type comes in. func (opts *Target) applyFlagsWithPrefix(fs *pflag.FlagSet, prefix, description string) { flagPrefix, notePrefix := applyPrefix(prefix, description) - fs.BoolVarP(&opts.isOCILayout, flagPrefix+"oci-layout", "", false, "Set "+notePrefix+"target as an OCI image layout.") + fs.BoolVarP(&opts.isOCILayout, flagPrefix+"oci-layout", "", false, "set "+notePrefix+"target as an OCI image layout") } // ApplyFlagsWithPrefix applies flags to a command flag set with a prefix string. diff --git a/cmd/oras/main.go b/cmd/oras/main.go index e85d87286..0e2fa038e 100644 --- a/cmd/oras/main.go +++ b/cmd/oras/main.go @@ -21,7 +21,7 @@ import ( "github.com/spf13/cobra" "oras.land/oras/cmd/oras/blob" "oras.land/oras/cmd/oras/manifest" - "oras.land/oras/cmd/oras/repository" + repository "oras.land/oras/cmd/oras/repo" "oras.land/oras/cmd/oras/tag" ) diff --git a/cmd/oras/manifest/cmd.go b/cmd/oras/manifest/cmd.go index 347106326..c68668614 100644 --- a/cmd/oras/manifest/cmd.go +++ b/cmd/oras/manifest/cmd.go @@ -22,7 +22,7 @@ import ( func Cmd() *cobra.Command { cmd := &cobra.Command{ Use: "manifest [command]", - Short: "[Preview] Manifest operations", + Short: "Manifest operations", } cmd.AddCommand( diff --git a/cmd/oras/manifest/delete.go b/cmd/oras/manifest/delete.go index 00f11f57b..da1d67638 100644 --- a/cmd/oras/manifest/delete.go +++ b/cmd/oras/manifest/delete.go @@ -41,10 +41,8 @@ func deleteCmd() *cobra.Command { cmd := &cobra.Command{ Use: "delete [flags] {:|@}", Aliases: []string{"remove", "rm"}, - Short: "[Preview] Delete a manifest from remote registry", - Long: `[Preview] Delete a manifest from remote registry - -** This command is in preview and under development. ** + Short: "Delete a manifest from remote registry", + Long: `Delete a manifest from remote registry Example - Delete a manifest tagged with 'v1' from repository 'localhost:5000/hello': oras manifest delete localhost:5000/hello:v1 diff --git a/cmd/oras/manifest/fetch.go b/cmd/oras/manifest/fetch.go index 135fa5b3f..36f062f85 100644 --- a/cmd/oras/manifest/fetch.go +++ b/cmd/oras/manifest/fetch.go @@ -44,10 +44,8 @@ func fetchCmd() *cobra.Command { var opts fetchOptions cmd := &cobra.Command{ Use: "fetch [flags] {:|@}", - Short: "[Preview] Fetch manifest of the target artifact", - Long: `[Preview] Fetch manifest of the target artifact - -** This command is in preview and under development. ** + Short: "Fetch manifest of the target artifact", + Long: `Fetch manifest of the target artifact Example - Fetch raw manifest from a registry: oras manifest fetch localhost:5000/hello:v1 diff --git a/cmd/oras/manifest/fetch_config.go b/cmd/oras/manifest/fetch_config.go index 7ee1962a8..e0245f968 100644 --- a/cmd/oras/manifest/fetch_config.go +++ b/cmd/oras/manifest/fetch_config.go @@ -46,10 +46,8 @@ func fetchConfigCmd() *cobra.Command { cmd := &cobra.Command{ Use: "fetch-config [flags] {:|@}", Aliases: []string{"get-config"}, - Short: "[Preview] Fetch the config of a manifest from a remote registry", - Long: `[Preview] Fetch the config of a manifest from a remote registry - -** This command is in preview and under development. ** + Short: "Fetch the config of a manifest from a remote registry", + Long: `Fetch the config of a manifest from a remote registry Example - Fetch the config: oras manifest fetch-config localhost:5000/hello:v1 diff --git a/cmd/oras/manifest/push.go b/cmd/oras/manifest/push.go index 031eb7d93..570023039 100644 --- a/cmd/oras/manifest/push.go +++ b/cmd/oras/manifest/push.go @@ -49,10 +49,8 @@ func pushCmd() *cobra.Command { var opts pushOptions cmd := &cobra.Command{ Use: "push [flags] [:[,][...]|@] ", - Short: "[Preview] Push a manifest to remote registry", - Long: `[Preview] Push a manifest to remote registry - -** This command is in preview and under development. ** + Short: "Push a manifest to remote registry", + Long: `Push a manifest to remote registry Example - Push a manifest to repository 'localhost:5000/hello' and tag with 'v1': oras manifest push localhost:5000/hello:v1 manifest.json diff --git a/cmd/oras/pull.go b/cmd/oras/pull.go index 4088d85bd..3bd1ffd7e 100644 --- a/cmd/oras/pull.go +++ b/cmd/oras/pull.go @@ -93,7 +93,7 @@ Example - Pull artifact files from an OCI layout archive 'layout.tar': cmd.Flags().BoolVarP(&opts.KeepOldFiles, "keep-old-files", "k", false, "do not replace existing files when pulling, treat them as errors") cmd.Flags().BoolVarP(&opts.PathTraversal, "allow-path-traversal", "T", false, "allow storing files out of the output directory") - cmd.Flags().BoolVarP(&opts.IncludeSubject, "include-subject", "", false, "recursively pull the subject of artifacts") + cmd.Flags().BoolVarP(&opts.IncludeSubject, "include-subject", "", false, "[Preview] recursively pull the subject of artifacts") 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") diff --git a/cmd/oras/repository/cmd.go b/cmd/oras/repo/cmd.go similarity index 94% rename from cmd/oras/repository/cmd.go rename to cmd/oras/repo/cmd.go index 9bd0c2486..bc1c39825 100644 --- a/cmd/oras/repository/cmd.go +++ b/cmd/oras/repo/cmd.go @@ -20,7 +20,7 @@ import ( func Cmd() *cobra.Command { cmd := &cobra.Command{ Use: "repo [command]", - Short: "[Preview] Repository operations", + Short: "Repository operations", Aliases: []string{"repository"}, } diff --git a/cmd/oras/repository/ls.go b/cmd/oras/repo/ls.go similarity index 92% rename from cmd/oras/repository/ls.go rename to cmd/oras/repo/ls.go index af273b69f..55ee0e29a 100644 --- a/cmd/oras/repository/ls.go +++ b/cmd/oras/repo/ls.go @@ -36,10 +36,8 @@ func listCmd() *cobra.Command { var opts repositoryOptions cmd := &cobra.Command{ Use: "ls [flags] ", - Short: "[Preview] List the repositories under the registry", - Long: `[Preview] List the repositories under the registry - -** This command is in preview and under development. ** + Short: "List the repositories under the registry", + Long: `List the repositories under the registry Example - List the repositories under the registry: oras repo ls localhost:5000 diff --git a/cmd/oras/repository/tags.go b/cmd/oras/repo/tags.go similarity index 90% rename from cmd/oras/repository/tags.go rename to cmd/oras/repo/tags.go index 513ff24c9..ed72cf138 100644 --- a/cmd/oras/repository/tags.go +++ b/cmd/oras/repo/tags.go @@ -36,10 +36,8 @@ func showTagsCmd() *cobra.Command { var opts showTagsOptions cmd := &cobra.Command{ Use: "tags [flags] ", - Short: "[Preview] Show tags of the target repository", - Long: `[Preview] Show tags of the target repository - -** This command is in preview and under development. ** + Short: "Show tags of the target repository", + Long: `Show tags of the target repository Example - Show tags of the target repository: oras repo tags localhost:5000/hello @@ -73,7 +71,7 @@ Example - Show tags associated with a digest: }, } cmd.Flags().StringVar(&opts.last, "last", "", "start after the tag specified by `last`") - cmd.Flags().BoolVar(&opts.excludeDigestTag, "exclude-digest-tags", false, "exclude all digest-like tags such as 'sha256-aaaa...'") + cmd.Flags().BoolVar(&opts.excludeDigestTag, "exclude-digest-tags", false, "[Preview] exclude all digest-like tags such as 'sha256-aaaa...'") option.ApplyFlags(&opts, cmd.Flags()) return cmd } @@ -96,7 +94,7 @@ func showTags(opts showTagsOptions) error { } filter = desc.Digest.String() } - logger.Infof("[Preview] Querying tags associated to %s, it may take a while.\n", filter) + logger.Infof("[Experimental] querying tags associated to %s, it may take a while...\n", filter) } return finder.Tags(ctx, opts.last, func(tags []string) error { for _, tag := range tags { diff --git a/cmd/oras/tag/tag.go b/cmd/oras/tag/tag.go index 91044bd9e..29c0f01e1 100644 --- a/cmd/oras/tag/tag.go +++ b/cmd/oras/tag/tag.go @@ -36,10 +36,8 @@ func TagCmd() *cobra.Command { var opts tagOptions cmd := &cobra.Command{ Use: "tag [flags] {:|@} [...]", - Short: "[Preview] Tag a manifest in the remote registry", - Long: `[Preview] Tag a manifest in the remote registry - -** This command is in preview and under development. ** + Short: "Tag a manifest in the remote registry", + Long: `Tag a manifest in the remote registry Example - Tag the manifest 'v1.0.1' in 'localhost:5000/hello' to 'v1.0.2': oras tag localhost:5000/hello:v1.0.1 v1.0.2 diff --git a/test/e2e/internal/testdata/feature/feature.go b/test/e2e/internal/testdata/feature/feature.go new file mode 100644 index 000000000..a593d2b2a --- /dev/null +++ b/test/e2e/internal/testdata/feature/feature.go @@ -0,0 +1,30 @@ +/* +Copyright The ORAS Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package feature + +var ( + Preview = struct { + Mark string + Description string + }{ + Mark: "[Preview]", + Description: "** This command is in preview and under development. **", + } + + Experimental = struct{ Mark string }{ + Mark: "[Experimental]", + } +) diff --git a/test/e2e/suite/command/attach.go b/test/e2e/suite/command/attach.go index 35eab9d6c..c9faa4180 100644 --- a/test/e2e/suite/command/attach.go +++ b/test/e2e/suite/command/attach.go @@ -19,10 +19,14 @@ import ( "encoding/json" "fmt" "path/filepath" + "regexp" . "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" . "github.com/onsi/gomega" + "github.com/onsi/gomega/gbytes" ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "oras.land/oras/test/e2e/internal/testdata/feature" "oras.land/oras/test/e2e/internal/testdata/foobar" . "oras.land/oras/test/e2e/internal/utils" "oras.land/oras/test/e2e/internal/utils/match" @@ -37,7 +41,9 @@ var _ = Describe("ORAS beginners:", func() { RunAndShowPreviewInHelp([]string{"attach"}) It("should show preview and help doc", func() { - ORAS("attach", "--help").MatchKeyWords("[Preview] Attach", PreviewDesc, ExampleDesc).Exec() + out := ORAS("attach", "--help").MatchKeyWords(feature.Preview.Mark+" Attach", feature.Preview.Description, ExampleDesc).Exec() + gomega.Expect(out).Should(gbytes.Say("--distribution-spec string\\s+%s", regexp.QuoteMeta(feature.Preview.Mark))) + gomega.Expect(out).Should(gbytes.Say("--image-spec string\\s+%s", regexp.QuoteMeta(feature.Experimental.Mark))) }) It("should fail when no subject reference provided", func() { diff --git a/test/e2e/suite/command/blob.go b/test/e2e/suite/command/blob.go index 8f868f1d7..bb6a6e96a 100644 --- a/test/e2e/suite/command/blob.go +++ b/test/e2e/suite/command/blob.go @@ -36,10 +36,7 @@ const ( var _ = Describe("ORAS beginners:", func() { repoFmt := fmt.Sprintf("command/blob/%%s/%d/%%s", GinkgoRandomSeed()) When("running blob command", func() { - RunAndShowPreviewInHelp([]string{"blob"}) - When("running `blob push`", func() { - RunAndShowPreviewInHelp([]string{"blob", "push"}, PreviewDesc, ExampleDesc) It("should fail to read blob content and password from stdin at the same time", func() { repo := fmt.Sprintf(repoFmt, "push", "password-stdin") ORAS("blob", "push", RegistryRef(Host, repo, ""), "--password-stdin", "-"). @@ -90,11 +87,9 @@ var _ = Describe("ORAS beginners:", func() { }) When("running `blob fetch`", func() { - RunAndShowPreviewInHelp([]string{"blob", "fetch"}, PreviewDesc, ExampleDesc) - It("should call sub-commands with aliases", func() { ORAS("blob", "get", "--help"). - MatchKeyWords("[Preview] Fetch", PreviewDesc, ExampleDesc). + MatchKeyWords(ExampleDesc). Exec() }) It("should have flag for prettifying JSON output", func() { @@ -130,8 +125,6 @@ var _ = Describe("ORAS beginners:", func() { }) When("running `blob delete`", func() { - RunAndShowPreviewInHelp([]string{"blob", "delete"}, PreviewDesc, ExampleDesc) - It("should fail if no blob reference is provided", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "no-ref") ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Digest), RegistryRef(Host, dstRepo, foobar.Digest)).Exec() diff --git a/test/e2e/suite/command/cp.go b/test/e2e/suite/command/cp.go index ca30a3638..bab07e22a 100644 --- a/test/e2e/suite/command/cp.go +++ b/test/e2e/suite/command/cp.go @@ -18,12 +18,16 @@ package command import ( "encoding/json" "fmt" + "regexp" "strings" . "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" . "github.com/onsi/gomega" + "github.com/onsi/gomega/gbytes" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2" + "oras.land/oras/test/e2e/internal/testdata/feature" "oras.land/oras/test/e2e/internal/testdata/foobar" ma "oras.land/oras/test/e2e/internal/testdata/multi_arch" . "oras.land/oras/test/e2e/internal/utils" @@ -35,10 +39,11 @@ func cpTestRepo(text string) string { var _ = Describe("ORAS beginners:", func() { When("running cp command", func() { - RunAndShowPreviewInHelp([]string{"copy"}) - - It("should show preview and help doc", func() { - ORAS("cp", "--help").MatchKeyWords("[Preview] Copy", PreviewDesc, ExampleDesc).Exec() + It("should show help doc with feature flags", func() { + out := ORAS("cp", "--help").MatchKeyWords("Copy", ExampleDesc).Exec() + gomega.Expect(out).Should(gbytes.Say("--from-distribution-spec string\\s+%s", regexp.QuoteMeta(feature.Preview.Mark))) + gomega.Expect(out).Should(gbytes.Say("-r, --recursive\\s+%s", regexp.QuoteMeta(feature.Preview.Mark))) + gomega.Expect(out).Should(gbytes.Say("--to-distribution-spec string\\s+%s", regexp.QuoteMeta(feature.Preview.Mark))) }) It("should fail when no reference provided", func() { diff --git a/test/e2e/suite/command/discover.go b/test/e2e/suite/command/discover.go index 9ba379a5f..f2db43b88 100644 --- a/test/e2e/suite/command/discover.go +++ b/test/e2e/suite/command/discover.go @@ -17,12 +17,16 @@ package command import ( "encoding/json" + "regexp" "strings" . "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" . "github.com/onsi/gomega" + "github.com/onsi/gomega/gbytes" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "gopkg.in/yaml.v2" + "oras.land/oras/test/e2e/internal/testdata/feature" "oras.land/oras/test/e2e/internal/testdata/foobar" "oras.land/oras/test/e2e/internal/testdata/multi_arch" . "oras.land/oras/test/e2e/internal/utils" @@ -48,7 +52,8 @@ var _ = Describe("ORAS beginners:", func() { RunAndShowPreviewInHelp([]string{"discover"}) It("should show preview and help doc", func() { - ORAS("discover", "--help").MatchKeyWords("[Preview] Discover", PreviewDesc, ExampleDesc).Exec() + out := ORAS("discover", "--help").MatchKeyWords(feature.Preview.Mark+" Discover", feature.Preview.Description, ExampleDesc).Exec() + gomega.Expect(out).Should(gbytes.Say("--distribution-spec string\\s+%s", regexp.QuoteMeta(feature.Preview.Mark))) }) It("should fail when no subject reference provided", func() { diff --git a/test/e2e/suite/command/manifest.go b/test/e2e/suite/command/manifest.go index c312e550e..1fa9d9279 100644 --- a/test/e2e/suite/command/manifest.go +++ b/test/e2e/suite/command/manifest.go @@ -22,9 +22,11 @@ import ( "strings" . "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "oras.land/oras/test/e2e/internal/testdata/feature" "oras.land/oras/test/e2e/internal/testdata/foobar" "oras.land/oras/test/e2e/internal/testdata/multi_arch" . "oras.land/oras/test/e2e/internal/utils" @@ -47,10 +49,12 @@ func validateTag(repoRef string, tag string, gone bool) { var _ = Describe("ORAS beginners:", func() { repoFmt := fmt.Sprintf("command/manifest/%%s/%d/%%s", GinkgoRandomSeed()) When("running manifest command", func() { - RunAndShowPreviewInHelp([]string{"manifest"}) - When("running `manifest push`", func() { - RunAndShowPreviewInHelp([]string{"manifest", "push"}, PreviewDesc, ExampleDesc) + It("should show help doc with feature flags", func() { + out := ORAS("manifest", "push", "--help").MatchKeyWords(ExampleDesc).Exec() + gomega.Expect(out).Should(gbytes.Say("--distribution-spec string\\s+%s", regexp.QuoteMeta(feature.Preview.Mark))) + }) + It("should have flag for prettifying JSON output", func() { ORAS("manifest", "push", "--help"). MatchKeyWords("--pretty", "prettify JSON"). @@ -66,10 +70,9 @@ var _ = Describe("ORAS beginners:", func() { }) When("running `manifest fetch`", func() { - RunAndShowPreviewInHelp([]string{"manifest", "fetch"}, PreviewDesc, ExampleDesc) It("should call sub-commands with aliases", func() { ORAS("manifest", "get", "--help"). - MatchKeyWords("[Preview] Fetch", PreviewDesc, ExampleDesc). + MatchKeyWords(ExampleDesc). Exec() }) It("should fail fetching manifest without reference provided", func() { @@ -80,6 +83,11 @@ var _ = Describe("ORAS beginners:", func() { }) }) When("running `manifest delete`", func() { + It("should show help doc with feature flags", func() { + out := ORAS("manifest", "delete", "--help").MatchKeyWords(ExampleDesc).Exec() + gomega.Expect(out).Should(gbytes.Say("--distribution-spec string\\s+%s", regexp.QuoteMeta(feature.Preview.Mark))) + }) + tempTag := "to-delete" It("should cancel deletion without confirmation", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "no-confirm") @@ -128,7 +136,7 @@ var _ = Describe("ORAS beginners:", func() { When("running `manifest fetch-config`", func() { It("should show preview hint in the doc", func() { ORAS("manifest", "fetch-config", "--help"). - MatchKeyWords(PreviewDesc, ExampleDesc, "[Preview]", "\nUsage:").Exec() + MatchKeyWords(ExampleDesc, "\nUsage:").Exec() }) It("should fail if no manifest reference provided", func() { diff --git a/test/e2e/suite/command/pull.go b/test/e2e/suite/command/pull.go index f113251b3..db5895da1 100644 --- a/test/e2e/suite/command/pull.go +++ b/test/e2e/suite/command/pull.go @@ -19,16 +19,28 @@ import ( "fmt" "os" "path/filepath" + "regexp" . "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" "oras.land/oras-go/v2" + "oras.land/oras/test/e2e/internal/testdata/feature" "oras.land/oras/test/e2e/internal/testdata/foobar" "oras.land/oras/test/e2e/internal/testdata/multi_arch" . "oras.land/oras/test/e2e/internal/utils" ) +var _ = Describe("ORAS beginners:", func() { + When("running pull command", func() { + It("should show help description with feature flags", func() { + out := ORAS("pull", "--help").MatchKeyWords(ExampleDesc).Exec().Out + gomega.Expect(out).Should(gbytes.Say("--include-subject\\s+%s", regexp.QuoteMeta(feature.Preview.Mark))) + }) + }) +}) + var _ = Describe("Remote registry users:", func() { When("pulling images from remote registry", func() { var ( diff --git a/test/e2e/suite/command/push.go b/test/e2e/suite/command/push.go index 83c702a7f..5a77dbb1c 100644 --- a/test/e2e/suite/command/push.go +++ b/test/e2e/suite/command/push.go @@ -19,14 +19,27 @@ import ( "bytes" "fmt" "path/filepath" + "regexp" . "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" + "github.com/onsi/gomega/gbytes" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2" + "oras.land/oras/test/e2e/internal/testdata/feature" . "oras.land/oras/test/e2e/internal/utils" "oras.land/oras/test/e2e/internal/utils/match" ) +var _ = Describe("ORAS beginners:", func() { + When("running push command", func() { + It("should show help description with feature flags", func() { + out := ORAS("push", "--help").MatchKeyWords(ExampleDesc).Exec().Out + gomega.Expect(out).Should(gbytes.Say("--image-spec string\\s+%s", regexp.QuoteMeta(feature.Experimental.Mark))) + }) + }) +}) + var _ = Describe("Remote registry users:", func() { layerDescriptorTemplate := `{"mediaType":"%s","digest":"sha256:fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9","size":3,"annotations":{"org.opencontainers.image.title":"foobar/bar"}}` tag := "e2e" diff --git a/test/e2e/suite/command/repo.go b/test/e2e/suite/command/repo.go index 48da66901..58a95792e 100644 --- a/test/e2e/suite/command/repo.go +++ b/test/e2e/suite/command/repo.go @@ -23,6 +23,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" + "oras.land/oras/test/e2e/internal/testdata/feature" "oras.land/oras/test/e2e/internal/testdata/foobar" "oras.land/oras/test/e2e/internal/testdata/multi_arch" . "oras.land/oras/test/e2e/internal/utils" @@ -30,14 +31,13 @@ import ( var _ = Describe("ORAS beginners:", func() { When("running repo command", func() { - RunAndShowPreviewInHelp([]string{"repo"}) When("running `repo ls`", func() { - It("should show preview in help", func() { - ORAS("repo", "ls", "--help").MatchKeyWords("[Preview] List", PreviewDesc, ExampleDesc).Exec() + It("should show help description", func() { + ORAS("repo", "ls", "--help").MatchKeyWords(ExampleDesc).Exec() }) It("should call sub-commands with aliases", func() { - ORAS("repository", "list", "--help").MatchKeyWords("[Preview] List", PreviewDesc, ExampleDesc).Exec() + ORAS("repository", "list", "--help").MatchKeyWords(ExampleDesc).Exec() }) It("should fail listing repositories if wrong registry provided", func() { @@ -46,12 +46,13 @@ var _ = Describe("ORAS beginners:", func() { }) }) When("running `repo tags`", func() { - It("should show preview in help", func() { - ORAS("repo", "tags", "--help").MatchKeyWords("[Preview] Show tags", PreviewDesc, ExampleDesc).Exec() + It("should show help description with feature flags", func() { + out := ORAS("repo", "tags", "--help").MatchKeyWords(ExampleDesc).Exec().Out + Expect(out).Should(gbytes.Say("--exclude-digest-tags\\s+%s", regexp.QuoteMeta(feature.Preview.Mark))) }) It("should call sub-commands with aliases", func() { - ORAS("repository", "show-tags", "--help").MatchKeyWords("[Preview] Show tags", PreviewDesc, ExampleDesc).Exec() + ORAS("repository", "show-tags", "--help").MatchKeyWords(ExampleDesc).Exec() }) It("should fail listing repositories if wrong registry provided", func() { @@ -123,12 +124,12 @@ var _ = Describe("Common registry users:", func() { // test viaTag := ORAS("repo", "tags", "-v", RegistryRef(Host, repo, foobar.Tag)). MatchKeyWords(tags...). - MatchErrKeyWords("Preview", foobar.Digest).Exec().Out + MatchErrKeyWords(feature.Experimental.Mark, foobar.Digest).Exec().Out Expect(viaTag).ShouldNot(gbytes.Say(multi_arch.Tag)) viaDigest := ORAS("repo", "tags", "-v", RegistryRef(Host, repo, foobar.Digest)). MatchKeyWords(tags...). - MatchErrKeyWords("Preview", foobar.Digest).Exec().Out + MatchErrKeyWords(feature.Experimental.Mark, foobar.Digest).Exec().Out Expect(viaDigest).ShouldNot(gbytes.Say(multi_arch.Tag)) }) }) diff --git a/test/e2e/suite/command/tag.go b/test/e2e/suite/command/tag.go index d080eaf8a..f35b56f64 100644 --- a/test/e2e/suite/command/tag.go +++ b/test/e2e/suite/command/tag.go @@ -28,7 +28,6 @@ import ( var _ = Describe("ORAS beginners:", func() { When("running repo command", func() { - RunAndShowPreviewInHelp([]string{"tag"}) It("should fail when no manifest reference provided", func() { ORAS("tag").ExpectFailure().MatchErrKeyWords("Error:").Exec() })