Files
moby/client/volume_remove.go
Sebastiaan van Stijn faee204c02 client: VolumeRemove: add output struct
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-28 15:42:33 +01:00

37 lines
872 B
Go

package client
import (
"context"
"net/url"
)
// VolumeRemoveOptions holds options for [Client.VolumeRemove].
type VolumeRemoveOptions struct {
// Force the removal of the volume
Force bool
}
// VolumeRemoveResult holds the result of [Client.VolumeRemove],
type VolumeRemoveResult struct {
// Add future fields here.
}
// VolumeRemove removes a volume from the docker host.
func (cli *Client) VolumeRemove(ctx context.Context, volumeID string, options VolumeRemoveOptions) (VolumeRemoveResult, error) {
volumeID, err := trimID("volume", volumeID)
if err != nil {
return VolumeRemoveResult{}, err
}
query := url.Values{}
if options.Force {
query.Set("force", "1")
}
resp, err := cli.delete(ctx, "/volumes/"+volumeID, query, nil)
defer ensureReaderClosed(resp)
if err != nil {
return VolumeRemoveResult{}, err
}
return VolumeRemoveResult{}, nil
}