Skip to content

Commit

Permalink
api/v2: document and consume count=-1
Browse files Browse the repository at this point in the history
The underlying code already knows how to consume count=-1 when fetching
all data points. This patch allows the server to accept such a value
from the client and pass it through.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
  • Loading branch information
stevekuznetsov authored and dims committed Apr 17, 2022
1 parent a429676 commit 808d2f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions cmd/internal/api/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,14 @@ func GetRequestOptions(r *http.Request) (v2.RequestOptions, error) {
}
count := r.URL.Query().Get("count")
if len(count) != 0 {
n, err := strconv.ParseUint(count, 10, 32)
n, err := strconv.Atoi(count)
if err != nil {
return opt, fmt.Errorf("failed to parse 'count' option: %v", count)
}
opt.Count = int(n)
if n < -1 {
return opt, fmt.Errorf("invalid 'count' option: only -1 and larger values allowed, not %d", n)
}
opt.Count = n
}
recursive := r.URL.Query().Get("recursive")
if recursive == "true" {
Expand Down
2 changes: 1 addition & 1 deletion info/v2/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ type FsInfo struct {
type RequestOptions struct {
// Type of container identifier specified - TypeName (default) or TypeDocker
IdType string `json:"type"`
// Number of stats to return
// Number of stats to return, -1 means no limit.
Count int `json:"count"`
// Whether to include stats for child subcontainers.
Recursive bool `json:"recursive"`
Expand Down

0 comments on commit 808d2f5

Please sign in to comment.