summaryrefslogtreecommitdiff
path: root/cmd/podman/secrets
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-08-22 15:46:47 -0400
committerGitHub <noreply@github.com>2022-08-22 15:46:47 -0400
commit51d4b88ce976708de88ce041a03d6d65dd4c8d0e (patch)
tree8f358e694b159f48352d3fd3df39696c98177999 /cmd/podman/secrets
parentaefd0aed3990848e77b706d673c23108092594a0 (diff)
parenteee0ec97e8eb7436208b7852e7e9ee5974384395 (diff)
downloadpodman-51d4b88ce976708de88ce041a03d6d65dd4c8d0e.tar.gz
podman-51d4b88ce976708de88ce041a03d6d65dd4c8d0e.tar.bz2
podman-51d4b88ce976708de88ce041a03d6d65dd4c8d0e.zip
Merge pull request #15392 from ashley-cui/quiet
Add quiet/q flag to podman secret ls
Diffstat (limited to 'cmd/podman/secrets')
-rw-r--r--cmd/podman/secrets/list.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/cmd/podman/secrets/list.go b/cmd/podman/secrets/list.go
index 8b1956eab..afa9b8887 100644
--- a/cmd/podman/secrets/list.go
+++ b/cmd/podman/secrets/list.go
@@ -34,6 +34,7 @@ type listFlagType struct {
format string
noHeading bool
filter []string
+ quiet bool
}
func init() {
@@ -43,13 +44,20 @@ func init() {
})
flags := lsCmd.Flags()
+
formatFlagName := "format"
flags.StringVar(&listFlag.format, formatFlagName, "{{.ID}}\t{{.Name}}\t{{.Driver}}\t{{.CreatedAt}}\t{{.UpdatedAt}}\t\n", "Format volume output using Go template")
_ = lsCmd.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteFormat(&entities.SecretInfoReport{}))
+
filterFlagName := "filter"
flags.StringSliceVarP(&listFlag.filter, filterFlagName, "f", []string{}, "Filter secret output")
_ = lsCmd.RegisterFlagCompletionFunc(filterFlagName, common.AutocompleteSecretFilters)
- flags.BoolVar(&listFlag.noHeading, "noheading", false, "Do not print headers")
+
+ noHeadingFlagName := "noheading"
+ flags.BoolVar(&listFlag.noHeading, noHeadingFlagName, false, "Do not print headers")
+
+ quietFlagName := "quiet"
+ flags.BoolVarP(&listFlag.quiet, quietFlagName, "q", false, "Print secret IDs only")
}
func ls(cmd *cobra.Command, args []string) error {
@@ -76,9 +84,21 @@ func ls(cmd *cobra.Command, args []string) error {
Driver: response.Spec.Driver.Name,
})
}
+
+ if listFlag.quiet && !cmd.Flags().Changed("format") {
+ return quietOut(listed)
+ }
+
return outputTemplate(cmd, listed)
}
+func quietOut(responses []*entities.SecretListReport) error {
+ for _, response := range responses {
+ fmt.Println(response.ID)
+ }
+ return nil
+}
+
func outputTemplate(cmd *cobra.Command, responses []*entities.SecretListReport) error {
headers := report.Headers(entities.SecretListReport{}, map[string]string{
"CreatedAt": "CREATED",