mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
These comments were added to enforce using the correct import path for
our packages ("github.com/docker/docker", not "github.com/moby/moby").
However, when working in go module mode (not GOPATH / vendor), they have
no effect, so their impact is limited.
Remove these imports in preparation of migrating our code to become an
actual go module.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
34 lines
759 B
Go
34 lines
759 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/url"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
)
|
|
|
|
// DiskUsage requests the current data usage from the daemon
|
|
func (cli *Client) DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error) {
|
|
var query url.Values
|
|
if len(options.Types) > 0 {
|
|
query = url.Values{}
|
|
for _, t := range options.Types {
|
|
query.Add("type", string(t))
|
|
}
|
|
}
|
|
|
|
resp, err := cli.get(ctx, "/system/df", query, nil)
|
|
defer ensureReaderClosed(resp)
|
|
if err != nil {
|
|
return types.DiskUsage{}, err
|
|
}
|
|
|
|
var du types.DiskUsage
|
|
if err := json.NewDecoder(resp.Body).Decode(&du); err != nil {
|
|
return types.DiskUsage{}, fmt.Errorf("Error retrieving disk usage: %v", err)
|
|
}
|
|
return du, nil
|
|
}
|