diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2022-04-24 06:03:53 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2022-04-24 06:07:10 -0400 |
commit | 0d83f4b768af46b95d6c5a652b2c56c2ae2093f0 (patch) | |
tree | 74b087a2cf032240f4d3566154b5ac1ade62553d | |
parent | f65f3320e1124c94db053c1f811487920ae2a70e (diff) | |
download | podman-0d83f4b768af46b95d6c5a652b2c56c2ae2093f0.tar.gz podman-0d83f4b768af46b95d6c5a652b2c56c2ae2093f0.tar.bz2 podman-0d83f4b768af46b95d6c5a652b2c56c2ae2093f0.zip |
Allow filtering of "removing", it is a valid status
Do not use a list of statuses outside of libpod to validate container
statuses. Removing status was never added to the list.
Fixes: https://github.com/containers/podman/issues/13986
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
-rw-r--r-- | pkg/domain/filters/containers.go | 4 | ||||
-rw-r--r-- | test/apiv2/20-containers.at | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/pkg/domain/filters/containers.go b/pkg/domain/filters/containers.go index 0557e75d6..3e5b9cad9 100644 --- a/pkg/domain/filters/containers.go +++ b/pkg/domain/filters/containers.go @@ -52,8 +52,8 @@ func GenerateContainerFilterFuncs(filter string, filterValues []string, r *libpo }, nil case "status": for _, filterValue := range filterValues { - if !util.StringInSlice(filterValue, []string{"created", "running", "paused", "stopped", "exited", "unknown"}) { - return nil, errors.Errorf("%s is not a valid status", filterValue) + if _, err := define.StringToContainerStatus(filterValue); err != nil { + return nil, err } } return func(c *libpod.Container) bool { diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at index 2d5754077..7a38dfea0 100644 --- a/test/apiv2/20-containers.at +++ b/test/apiv2/20-containers.at @@ -321,7 +321,11 @@ t GET containers/json?filters='garb1age}' 500 \ t GET containers/json?filters='{"label":["testl' 500 \ .cause="unexpected end of JSON input" + #libpod api list containers sanity checks +t GET libpod/containers/json?filters='{"status":["removing"]}' 200 length=0 +t GET libpod/containers/json?filters='{"status":["bogus"]}' 500 \ + .cause="invalid argument" t GET libpod/containers/json?filters='garb1age}' 500 \ .cause="invalid character 'g' looking for beginning of value" t GET libpod/containers/json?filters='{"label":["testl' 500 \ |