diff options
| author | Sebastiaan van Stijn <github@gone.nl> | 2022-03-15 14:53:46 +0100 |
|---|---|---|
| committer | Sebastiaan van Stijn <github@gone.nl> | 2022-03-15 14:53:46 +0100 |
| commit | 8ba83f63a0e9f6133c9033e25cda9ebee37bffa2 (patch) | |
| tree | 227b763276b8de94093754ae4600172ae84e401f /client | |
| parent | a6919e12b103aab6eb95a67450b2a487bfec1097 (diff) | |
| download | docker-8ba83f63a0e9f6133c9033e25cda9ebee37bffa2.tar.gz | |
client: ImageSearch(): don't send limit if none was specified
The API defines a default limit for searches, but when removing the
default from the cli, the client still sends "0" as a limit, which
is not allowed by existing versions of the API:
docker search --limit=0 busybox
Error response from daemon: Limit 0 is outside the range of [1, 100]
This patch changes the client so that no limit is sent if none was set ("0"),
allowing the daemon to use its (or the registry's) default.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'client')
| -rw-r--r-- | client/image_search.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/client/image_search.go b/client/image_search.go index 5f40a22a96..e69fa37225 100644 --- a/client/image_search.go +++ b/client/image_search.go @@ -3,8 +3,8 @@ package client // import "github.com/docker/docker/client" import ( "context" "encoding/json" - "fmt" "net/url" + "strconv" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" @@ -18,7 +18,9 @@ func (cli *Client) ImageSearch(ctx context.Context, term string, options types.I var results []registry.SearchResult query := url.Values{} query.Set("term", term) - query.Set("limit", fmt.Sprintf("%d", options.Limit)) + if options.Limit > 0 { + query.Set("limit", strconv.Itoa(options.Limit)) + } if options.Filters.Len() > 0 { filterJSON, err := filters.ToJSON(options.Filters) |
