(ctx context.Context, dockerCli command.Cli, volumeID, availability string, flags *pflag.FlagSet)
| 40 | } |
| 41 | |
| 42 | func 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 | } |
no test coverage detected
searching dependent graphs…