github.com/moby/docker@v26.1.3+incompatible/client/volume_prune.go (about) 1 package client // import "github.com/docker/docker/client" 2 3 import ( 4 "context" 5 "encoding/json" 6 "fmt" 7 8 "github.com/docker/docker/api/types" 9 "github.com/docker/docker/api/types/filters" 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(ctx, "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 defer ensureReaderClosed(serverResp) 27 if err != nil { 28 return report, err 29 } 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 }