Files
moby/client/volume_update.go
Sebastiaan van Stijn b20c3db932 client: request: use consistent order or arguments
Make `body` the last argument, so that requests can be inlined on call-sites.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-08-29 14:14:26 +02:00

41 lines
1.1 KiB
Go

package client
import (
"context"
"net/url"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/api/types/volume"
)
// VolumeUpdateOptions holds options for [Client.VolumeUpdate].
type VolumeUpdateOptions struct {
Version swarm.Version
// Spec is the ClusterVolumeSpec to update the volume to.
Spec *volume.ClusterVolumeSpec `json:"Spec,omitempty"`
}
// VolumeUpdateResult holds the result of [Client.VolumeUpdate],
type VolumeUpdateResult struct {
// Add future fields here.
}
// VolumeUpdate updates a volume. This only works for Cluster Volumes, and
// only some fields can be updated.
func (cli *Client) VolumeUpdate(ctx context.Context, volumeID string, options VolumeUpdateOptions) (VolumeUpdateResult, error) {
volumeID, err := trimID("volume", volumeID)
if err != nil {
return VolumeUpdateResult{}, err
}
query := url.Values{}
query.Set("version", options.Version.String())
resp, err := cli.put(ctx, "/volumes/"+volumeID, query, nil, options)
defer ensureReaderClosed(resp)
if err != nil {
return VolumeUpdateResult{}, err
}
return VolumeUpdateResult{}, nil
}