-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Expand file tree
/
Copy pathvolume_remove.go
More file actions
36 lines (31 loc) · 872 Bytes
/
volume_remove.go
File metadata and controls
36 lines (31 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
}