summaryrefslogtreecommitdiff
path: root/pkg/ps
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2020-11-17 16:43:17 +0100
committerPaul Holzinger <paul.holzinger@web.de>2020-11-18 11:36:06 +0100
commit4f427a89cbc0814c25dd4b562ddf4ff4e568a005 (patch)
tree0a0b18c76a96649e0a3482efe2c2b76514dd1a23 /pkg/ps
parent3502860e1cfe1042aca7a8de8446360662a5a2fd (diff)
downloadpodman-4f427a89cbc0814c25dd4b562ddf4ff4e568a005.tar.gz
podman-4f427a89cbc0814c25dd4b562ddf4ff4e568a005.tar.bz2
podman-4f427a89cbc0814c25dd4b562ddf4ff4e568a005.zip
Align the podman ps --filter behavior with docker
All of our filters worked exclusive resulting in `--filter status=created --filter status=exited` to return nothing. In docker filters with the same key work inclusive with the only exception being `label` which is exclusive. Filters with different keys always work exclusive. This PR aims to match the docker behavior with podman. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'pkg/ps')
-rw-r--r--pkg/ps/ps.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/pkg/ps/ps.go b/pkg/ps/ps.go
index 96b2d754f..3dd7eb0c6 100644
--- a/pkg/ps/ps.go
+++ b/pkg/ps/ps.go
@@ -21,19 +21,17 @@ import (
func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOptions) ([]entities.ListContainer, error) {
var (
- filterFuncs []libpod.ContainerFilter
- pss = []entities.ListContainer{}
+ pss = []entities.ListContainer{}
)
+ filterFuncs := make([]libpod.ContainerFilter, 0, len(options.Filters))
all := options.All || options.Last > 0
if len(options.Filters) > 0 {
for k, v := range options.Filters {
- for _, val := range v {
- generatedFunc, err := lpfilters.GenerateContainerFilterFuncs(k, val, runtime)
- if err != nil {
- return nil, err
- }
- filterFuncs = append(filterFuncs, generatedFunc)
+ generatedFunc, err := lpfilters.GenerateContainerFilterFuncs(k, v, runtime)
+ if err != nil {
+ return nil, err
}
+ filterFuncs = append(filterFuncs, generatedFunc)
}
}
@@ -43,7 +41,7 @@ func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOp
all = true
}
if !all {
- runningOnly, err := lpfilters.GenerateContainerFilterFuncs("status", define.ContainerStateRunning.String(), runtime)
+ runningOnly, err := lpfilters.GenerateContainerFilterFuncs("status", []string{define.ContainerStateRunning.String()}, runtime)
if err != nil {
return nil, err
}