7d62e40f7e
Since Go 1.7, context is a standard package. Since Go 1.9, everything that is provided by "x/net/context" is a couple of type aliases to types in "context". Many vendored packages still use x/net/context, so vendor entry remains for now. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
26 lines
598 B
Go
26 lines
598 B
Go
package client // import "github.com/docker/docker/client"
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
)
|
|
|
|
// DiskUsage requests the current data usage from the daemon
|
|
func (cli *Client) DiskUsage(ctx context.Context) (types.DiskUsage, error) {
|
|
var du types.DiskUsage
|
|
|
|
serverResp, err := cli.get(ctx, "/system/df", nil, nil)
|
|
if err != nil {
|
|
return du, err
|
|
}
|
|
defer ensureReaderClosed(serverResp)
|
|
|
|
if err := json.NewDecoder(serverResp.body).Decode(&du); err != nil {
|
|
return du, fmt.Errorf("Error retrieving disk usage: %v", err)
|
|
}
|
|
|
|
return du, nil
|
|
}
|