From 51862ccf14e228b1b090166baa6b4fdd1b3acf34 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Tue, 10 Jan 2023 14:20:22 -0500 Subject: [PATCH 1/2] crane: support --omit-digest-tags in crane ls --- cmd/crane/cmd/list.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/crane/cmd/list.go b/cmd/crane/cmd/list.go index 417b37218..3902ccdef 100644 --- a/cmd/crane/cmd/list.go +++ b/cmd/crane/cmd/list.go @@ -16,6 +16,7 @@ package cmd import ( "fmt" + "strings" "github.com/google/go-containerregistry/pkg/crane" "github.com/google/go-containerregistry/pkg/name" @@ -24,7 +25,7 @@ import ( // NewCmdList creates a new cobra.Command for the ls subcommand. func NewCmdList(options *[]crane.Option) *cobra.Command { - var fullRef bool + var fullRef, omitDigestTags bool cmd := &cobra.Command{ Use: "ls REPO", Short: "List the tags in a repo", @@ -42,6 +43,10 @@ func NewCmdList(options *[]crane.Option) *cobra.Command { } for _, tag := range tags { + if omitDigestTags && strings.HasPrefix(tag, "sha256-") { + continue + } + if fullRef { fmt.Println(r.Tag(tag)) } else { @@ -52,5 +57,6 @@ func NewCmdList(options *[]crane.Option) *cobra.Command { }, } cmd.Flags().BoolVar(&fullRef, "full-ref", false, "(Optional) if true, print the full image reference") + cmd.Flags().BoolVar(&omitDigestTags, "omit-digest-tags", false, "(Optional), if true, omit digest tags (e.g., ':sha256-...')") return cmd } From 3228ae251c562ed6c4482bae1ed97f19d97793c8 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Wed, 11 Jan 2023 14:34:31 -0500 Subject: [PATCH 2/2] generate markdown docs --- cmd/crane/doc/crane_ls.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/crane/doc/crane_ls.md b/cmd/crane/doc/crane_ls.md index a4c5ceed0..6616820b1 100644 --- a/cmd/crane/doc/crane_ls.md +++ b/cmd/crane/doc/crane_ls.md @@ -9,8 +9,9 @@ crane ls REPO [flags] ### Options ``` - --full-ref (Optional) if true, print the full image reference - -h, --help help for ls + --full-ref (Optional) if true, print the full image reference + -h, --help help for ls + --omit-digest-tags (Optional), if true, omit digest tags (e.g., ':sha256-...') ``` ### Options inherited from parent commands