github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/client/volume_prune.go (about) 1 package client 2 3 import ( 4 "encoding/json" 5 "fmt" 6 7 "github.com/docker/docker/api/types" 8 "github.com/docker/docker/api/types/filters" 9 "golang.org/x/net/context" 10 ) 11 12 // VolumesPrune requests the daemon to delete unused data 13 func (cli *Client) VolumesPrune(ctx context.Context, pruneFilters filters.Args) (types.VolumesPruneReport, error) { 14 var report types.VolumesPruneReport 15 16 if err := cli.NewVersionError("1.25", "volume prune"); err != nil { 17 return report, err 18 } 19 20 query, err := getFiltersQuery(pruneFilters) 21 if err != nil { 22 return report, err 23 } 24 25 serverResp, err := cli.post(ctx, "/volumes/prune", query, nil, nil) 26 if err != nil { 27 return report, err 28 } 29 defer ensureReaderClosed(serverResp) 30 31 if err := json.NewDecoder(serverResp.body).Decode(&report); err != nil { 32 return report, fmt.Errorf("Error retrieving volume prune report: %v", err) 33 } 34 35 return report, nil 36 }