2018-02-05 16:05:59 -05:00
|
|
|
package client // import "github.com/docker/docker/client"
|
2017-05-15 17:54:27 -04:00
|
|
|
|
|
|
|
import (
|
2018-04-19 18:30:59 -04:00
|
|
|
"context"
|
2017-05-15 17:54:27 -04:00
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|