(ctx context.Context, dockerCLI command.Cli, opts *stopOptions)
| 57 | } |
| 58 | |
| 59 | func runStop(ctx context.Context, dockerCLI command.Cli, opts *stopOptions) error { |
| 60 | var timeout *int |
| 61 | if opts.timeoutChanged { |
| 62 | timeout = &opts.timeout |
| 63 | } |
| 64 | |
| 65 | apiClient := dockerCLI.Client() |
| 66 | errChan := parallelOperation(ctx, opts.containers, func(ctx context.Context, id string) error { |
| 67 | _, err := apiClient.ContainerStop(ctx, id, client.ContainerStopOptions{ |
| 68 | Signal: opts.signal, |
| 69 | Timeout: timeout, |
| 70 | }) |
| 71 | return err |
| 72 | }) |
| 73 | var errs []error |
| 74 | for _, ctr := range opts.containers { |
| 75 | if err := <-errChan; err != nil { |
| 76 | errs = append(errs, err) |
| 77 | continue |
| 78 | } |
| 79 | _, _ = fmt.Fprintln(dockerCLI.Out(), ctr) |
| 80 | } |
| 81 | return errors.Join(errs...) |
| 82 | } |
no test coverage detected
searching dependent graphs…