Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crane: support --omit-digest-tags in crane ls #1528

Merged
merged 2 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cmd/crane/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package cmd

import (
"fmt"
"strings"

"github.com/google/go-containerregistry/pkg/crane"
"github.com/google/go-containerregistry/pkg/name"
Expand All @@ -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",
Expand All @@ -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 {
Expand All @@ -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
}
5 changes: 3 additions & 2 deletions cmd/crane/doc/crane_ls.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.