Files
moby/client/volume_remove.go
Sebastiaan van Stijn 9fc12daf80 client: remove version-gate for "--force" on "volume remove"
The `force` option on volume remove was added in [moby@6c5c34d] (docker
1.13.0-rc1, API v1.25), but did not gate the feature to API version, so
effectively introduced it to all existing API versions. After this,
[moby@e98e4a7] enabled experimental features by default, and added API
version gates, but only did so on the client side, so the daemon / API
server would continue to accept the `force` option on any API version.

Let's remove this code, given that:

- API v1.24 is the oldest API version we still handle, and only as fallback.
- This code silently discards the user's option (no warning / error)
- Every current version of the daemon handles the option, regardless
  of API version (only a 9+ year old daemon wouldn't handle it).

[moby@6c5c34d]: 6c5c34d50d
[moby@e98e4a7]: e98e4a7111

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-18 18:01:49 +02:00

23 lines
448 B
Go

package client
import (
"context"
"net/url"
)
// VolumeRemove removes a volume from the docker host.
func (cli *Client) VolumeRemove(ctx context.Context, volumeID string, force bool) error {
volumeID, err := trimID("volume", volumeID)
if err != nil {
return err
}
query := url.Values{}
if force {
query.Set("force", "1")
}
resp, err := cli.delete(ctx, "/volumes/"+volumeID, query, nil)
defer ensureReaderClosed(resp)
return err
}