2018-02-05 16:05:59 -05:00
|
|
|
package client // import "github.com/docker/docker/client"
|
2016-09-22 17:04:34 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
2016-11-17 00:46:37 -05:00
|
|
|
"github.com/docker/docker/api/types/filters"
|
2016-09-22 17:04:34 -04:00
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
// VolumesPrune requests the daemon to delete unused data
|
2016-11-17 00:46:37 -05:00
|
|
|
func (cli *Client) VolumesPrune(ctx context.Context, pruneFilters filters.Args) (types.VolumesPruneReport, error) {
|
2016-09-22 17:04:34 -04:00
|
|
|
var report types.VolumesPruneReport
|
|
|
|
|
2016-11-02 20:43:32 -04:00
|
|
|
if err := cli.NewVersionError("1.25", "volume prune"); err != nil {
|
|
|
|
return report, err
|
|
|
|
}
|
|
|
|
|
2016-11-17 00:46:37 -05:00
|
|
|
query, err := getFiltersQuery(pruneFilters)
|
|
|
|
if err != nil {
|
|
|
|
return report, err
|
|
|
|
}
|
|
|
|
|
|
|
|
serverResp, err := cli.post(ctx, "/volumes/prune", query, nil, nil)
|
2016-09-22 17:04:34 -04:00
|
|
|
if err != nil {
|
|
|
|
return report, err
|
|
|
|
}
|
|
|
|
defer ensureReaderClosed(serverResp)
|
|
|
|
|
|
|
|
if err := json.NewDecoder(serverResp.body).Decode(&report); err != nil {
|
2017-02-12 21:16:57 -05:00
|
|
|
return report, fmt.Errorf("Error retrieving volume prune report: %v", err)
|
2016-09-22 17:04:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return report, nil
|
|
|
|
}
|