summaryrefslogtreecommitdiff
path: root/cmd/podman/secrets/list.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-12-14 18:40:58 +0100
committerGitHub <noreply@github.com>2021-12-14 18:40:58 +0100
commita0894b5ecd6c64d30b82a7b79bc1e2e87c7f0a4e (patch)
treef29f820c85da215b2783ceab5d8284698ce85150 /cmd/podman/secrets/list.go
parent1884bd8873b6e60c0a590424cadd192cafb26c5f (diff)
parent50501f49a327a2f5c7f1c6746f9fde482c877387 (diff)
downloadpodman-a0894b5ecd6c64d30b82a7b79bc1e2e87c7f0a4e.tar.gz
podman-a0894b5ecd6c64d30b82a7b79bc1e2e87c7f0a4e.tar.bz2
podman-a0894b5ecd6c64d30b82a7b79bc1e2e87c7f0a4e.zip
Merge pull request #12586 from jmguzik/secret-cmd
Add secret list --filter to cli
Diffstat (limited to 'cmd/podman/secrets/list.go')
-rw-r--r--cmd/podman/secrets/list.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/cmd/podman/secrets/list.go b/cmd/podman/secrets/list.go
index 255d9ae1a..2074ab973 100644
--- a/cmd/podman/secrets/list.go
+++ b/cmd/podman/secrets/list.go
@@ -8,6 +8,7 @@ import (
"github.com/containers/common/pkg/completion"
"github.com/containers/common/pkg/report"
"github.com/containers/podman/v3/cmd/podman/common"
+ "github.com/containers/podman/v3/cmd/podman/parse"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/validate"
"github.com/containers/podman/v3/pkg/domain/entities"
@@ -32,6 +33,7 @@ var (
type listFlagType struct {
format string
noHeading bool
+ filter []string
}
func init() {
@@ -44,14 +46,26 @@ func init() {
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")
}
func ls(cmd *cobra.Command, args []string) error {
- responses, err := registry.ContainerEngine().SecretList(context.Background(), entities.SecretListRequest{})
+ var err error
+ lsOpts := entities.SecretListRequest{}
+
+ lsOpts.Filters, err = parse.FilterArgumentsIntoFilters(listFlag.filter)
+ if err != nil {
+ return err
+ }
+
+ responses, err := registry.ContainerEngine().SecretList(context.Background(), lsOpts)
if err != nil {
return err
}
+
listed := make([]*entities.SecretListReport, 0, len(responses))
for _, response := range responses {
listed = append(listed, &entities.SecretListReport{