mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
31 lines
722 B
Go
31 lines
722 B
Go
|
package client
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/docker/docker/api/types"
|
||
|
"golang.org/x/net/context"
|
||
|
)
|
||
|
|
||
|
// BuildCachePrune requests the daemon to delete unused cache data
|
||
|
func (cli *Client) BuildCachePrune(ctx context.Context) (*types.BuildCachePruneReport, error) {
|
||
|
if err := cli.NewVersionError("1.31", "build prune"); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
report := types.BuildCachePruneReport{}
|
||
|
|
||
|
serverResp, err := cli.post(ctx, "/build/prune", nil, nil, nil)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
defer ensureReaderClosed(serverResp)
|
||
|
|
||
|
if err := json.NewDecoder(serverResp.body).Decode(&report); err != nil {
|
||
|
return nil, fmt.Errorf("Error retrieving disk usage: %v", err)
|
||
|
}
|
||
|
|
||
|
return &report, nil
|
||
|
}
|