diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-11-18 21:16:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-18 21:16:21 +0100 |
commit | 4434bd797842c3015c0e6132eaf2509fed370c26 (patch) | |
tree | 07576e5d9c5b37f06a48bc027ce1c1d73852c8e7 /pkg | |
parent | 8672c4dea05366ae65c609a4d7f7d848d1cf04e0 (diff) | |
parent | e7fd9234cd0e6a23e32dd31c912ac47883b59738 (diff) | |
download | podman-4434bd797842c3015c0e6132eaf2509fed370c26.tar.gz podman-4434bd797842c3015c0e6132eaf2509fed370c26.tar.bz2 podman-4434bd797842c3015c0e6132eaf2509fed370c26.zip |
Merge pull request #8395 from Luap99/podman-pod-ps-filters
Align the podman pod ps --filter behavior with podman ps
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/api/handlers/utils/pods.go | 14 | ||||
-rw-r--r-- | pkg/domain/infra/abi/pods.go | 17 |
2 files changed, 13 insertions, 18 deletions
diff --git a/pkg/api/handlers/utils/pods.go b/pkg/api/handlers/utils/pods.go index 54ebe2d29..7506dbfd1 100644 --- a/pkg/api/handlers/utils/pods.go +++ b/pkg/api/handlers/utils/pods.go @@ -11,8 +11,7 @@ import ( func GetPods(w http.ResponseWriter, r *http.Request) ([]*entities.ListPodsReport, error) { var ( - pods []*libpod.Pod - filters []libpod.PodFilter + pods []*libpod.Pod ) runtime := r.Context().Value("runtime").(*libpod.Runtime) decoder := r.Context().Value("decoder").(*schema.Decoder) @@ -30,14 +29,13 @@ func GetPods(w http.ResponseWriter, r *http.Request) ([]*entities.ListPodsReport UnSupportedParameter("digests") } + filters := make([]libpod.PodFilter, 0, len(query.Filters)) for k, v := range query.Filters { - for _, filter := range v { - f, err := lpfilters.GeneratePodFilterFunc(k, filter) - if err != nil { - return nil, err - } - filters = append(filters, f) + f, err := lpfilters.GeneratePodFilterFunc(k, v) + if err != nil { + return nil, err } + filters = append(filters, f) } pods, err := runtime.Pods(filters...) if err != nil { diff --git a/pkg/domain/infra/abi/pods.go b/pkg/domain/infra/abi/pods.go index 258640a81..11374e513 100644 --- a/pkg/domain/infra/abi/pods.go +++ b/pkg/domain/infra/abi/pods.go @@ -282,20 +282,17 @@ func (ic *ContainerEngine) PodTop(ctx context.Context, options entities.PodTopOp func (ic *ContainerEngine) PodPs(ctx context.Context, options entities.PodPSOptions) ([]*entities.ListPodsReport, error) { var ( - err error - filters = []libpod.PodFilter{} - pds = []*libpod.Pod{} + err error + pds = []*libpod.Pod{} ) + filters := make([]libpod.PodFilter, 0, len(options.Filters)) for k, v := range options.Filters { - for _, filter := range v { - f, err := lpfilters.GeneratePodFilterFunc(k, filter) - if err != nil { - return nil, err - } - filters = append(filters, f) - + f, err := lpfilters.GeneratePodFilterFunc(k, v) + if err != nil { + return nil, err } + filters = append(filters, f) } if options.Latest { pod, err := ic.Libpod.GetLatestPod() |