(ctx context.Context, dockerCLI command.Cli, options *serviceOptions, serviceID string)
| 33 | } |
| 34 | |
| 35 | func runRollback(ctx context.Context, dockerCLI command.Cli, options *serviceOptions, serviceID string) error { |
| 36 | apiClient := dockerCLI.Client() |
| 37 | |
| 38 | res, err := apiClient.ServiceInspect(ctx, serviceID, client.ServiceInspectOptions{}) |
| 39 | if err != nil { |
| 40 | return err |
| 41 | } |
| 42 | |
| 43 | response, err := apiClient.ServiceUpdate(ctx, res.Service.ID, client.ServiceUpdateOptions{ |
| 44 | Version: res.Service.Version, |
| 45 | Spec: res.Service.Spec, |
| 46 | Rollback: "previous", // TODO(thaJeztah): this should have a const defined |
| 47 | }) |
| 48 | if err != nil { |
| 49 | return err |
| 50 | } |
| 51 | |
| 52 | for _, warning := range response.Warnings { |
| 53 | _, _ = fmt.Fprintln(dockerCLI.Err(), warning) |
| 54 | } |
| 55 | |
| 56 | _, _ = fmt.Fprintln(dockerCLI.Out(), serviceID) |
| 57 | |
| 58 | if options.detach { |
| 59 | return nil |
| 60 | } |
| 61 | |
| 62 | return WaitOnService(ctx, dockerCLI, serviceID, options.quiet) |
| 63 | } |
no test coverage detected
searching dependent graphs…