1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

client: container ps: don't set "limit" if none was set

both -1 and 0 are accepted as "no limit", so don't send the
limit option if no limit was set. For simplicity, we're ignoring
values <= 0.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-03-29 16:43:33 +02:00
parent 88e1fec490
commit 890231f46b
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
2 changed files with 4 additions and 4 deletions

View file

@ -18,7 +18,7 @@ func (cli *Client) ContainerList(ctx context.Context, options types.ContainerLis
query.Set("all", "1") query.Set("all", "1")
} }
if options.Limit != -1 { if options.Limit > 0 {
query.Set("limit", strconv.Itoa(options.Limit)) query.Set("limit", strconv.Itoa(options.Limit))
} }

View file

@ -39,8 +39,8 @@ func TestContainerList(t *testing.T) {
return nil, fmt.Errorf("all not set in URL query properly. Expected '1', got %s", all) return nil, fmt.Errorf("all not set in URL query properly. Expected '1', got %s", all)
} }
limit := query.Get("limit") limit := query.Get("limit")
if limit != "0" { if limit != "" {
return nil, fmt.Errorf("limit should have not be present in query. Expected '0', got %s", limit) return nil, fmt.Errorf("limit should have not be present in query, got %s", limit)
} }
since := query.Get("since") since := query.Get("since")
if since != "container" { if since != "container" {
@ -48,7 +48,7 @@ func TestContainerList(t *testing.T) {
} }
before := query.Get("before") before := query.Get("before")
if before != "" { if before != "" {
return nil, fmt.Errorf("before should have not be present in query, go %s", before) return nil, fmt.Errorf("before should have not be present in query, got %s", before)
} }
size := query.Get("size") size := query.Get("size")
if size != "1" { if size != "1" {