MCPcopy Index your code
hub / github.com/docker/cli / runUpdate

Function runUpdate

cli/command/volume/update.go:42–66  ·  view source on GitHub ↗
(ctx context.Context, dockerCli command.Cli, volumeID, availability string, flags *pflag.FlagSet)

Source from the content-addressed store, hash-verified

40}
41
42func runUpdate(ctx context.Context, dockerCli command.Cli, volumeID, availability string, flags *pflag.FlagSet) error {
43 // TODO(dperny): For this earliest version, the only thing that can be
44 // updated is Availability, which is necessary because to delete a cluster
45 // volume, the availability must first be set to "drain"
46
47 apiClient := dockerCli.Client()
48
49 res, err := apiClient.VolumeInspect(ctx, volumeID, client.VolumeInspectOptions{})
50 if err != nil {
51 return err
52 }
53
54 if res.Volume.ClusterVolume == nil {
55 return errors.New("can only update cluster volumes")
56 }
57
58 if flags.Changed("availability") {
59 res.Volume.ClusterVolume.Spec.Availability = volume.Availability(availability)
60 }
61 _, err = apiClient.VolumeUpdate(ctx, res.Volume.ClusterVolume.ID, client.VolumeUpdateOptions{
62 Version: res.Volume.ClusterVolume.Version,
63 Spec: &res.Volume.ClusterVolume.Spec,
64 })
65 return err
66}

Callers 1

newUpdateCommandFunction · 0.70

Calls 3

VolumeInspectMethod · 0.80
ClientMethod · 0.65
AvailabilityMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…