Skip to content

Commit

Permalink
Allow filtering of "removing", it is a valid status
Browse files Browse the repository at this point in the history
Do not use a list of statuses outside of libpod to validate container
statuses.  Removing status was never added to the list.

Fixes: #13986

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Apr 24, 2022
1 parent f65f332 commit 0d83f4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/domain/filters/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions test/apiv2/20-containers.at
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 0d83f4b

Please sign in to comment.