-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add --quiet to podman artifact ls #29530
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ type listFlagType struct { | |
| format string | ||
| noHeading bool | ||
| noTrunc bool | ||
| quiet bool | ||
| } | ||
|
|
||
| type artifactListOutput struct { | ||
|
|
@@ -76,6 +77,7 @@ func init() { | |
| _ = listCmd.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteFormat(&artifactListOutput{})) | ||
| flags.BoolVarP(&listFlag.noHeading, "noheading", "n", false, "Do not print column headings") | ||
| flags.BoolVar(&listFlag.noTrunc, "no-trunc", false, "Do not truncate output") | ||
| flags.BoolVarP(&listFlag.quiet, "quiet", "q", false, "Display only artifact digests") | ||
| } | ||
|
|
||
| func list(cmd *cobra.Command, _ []string) error { | ||
|
|
@@ -137,6 +139,13 @@ func outputTemplate(cmd *cobra.Command, lrs []*entities.ArtifactListReport) erro | |
| }) | ||
| } | ||
|
|
||
| if listFlag.quiet && !cmd.Flags().Changed("format") { | ||
| for _, a := range artifacts { | ||
| fmt.Println(a.Digest) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe for a clean approach, I would split code into two functions: |
||
| } | ||
| return nil | ||
| } | ||
|
|
||
| headers := report.Headers(artifactListOutput{}, map[string]string{ | ||
| "REPOSITORY": "REPOSITORY", | ||
| "Tag": "TAG", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,16 @@ var _ = Describe("Podman artifact", func() { | |
| Expect(noHeaderOutput).To(HaveLen(2)) | ||
| Expect(noHeaderOutput).ToNot(ContainElement("REPOSITORY")) | ||
|
|
||
| // check with --quiet and verify only the (truncated) digests are printed | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add coverage for the |
||
| quietSession := podmanTest.PodmanExitCleanly("artifact", "ls", "--quiet") | ||
| quietOutput := quietSession.OutputToStringArray() | ||
| Expect(quietOutput).To(HaveLen(2)) | ||
| Expect(quietOutput).ToNot(ContainElement("REPOSITORY")) | ||
| Expect(quietOutput).To(ContainElement(defaultOutput)) | ||
| for _, digest := range quietOutput { | ||
| Expect(digest).To(HaveLen(12)) | ||
| } | ||
|
|
||
| // Check if .VirtualSize is reported correctly | ||
| virtualSizeFormatSession := podmanTest.PodmanExitCleanly("artifact", "ls", "--format", "{{.VirtualSize}}") | ||
| virtualSizes := virtualSizeFormatSession.OutputToStringArray() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
--quiet+--formatinteraction silently ignores--quiet(format wins). Should end with an error:quiet and format flags cannot be used together.