(ctx context.Context, dockerCLI command.Cli, opts *rmOptions)
| 70 | } |
| 71 | |
| 72 | func runRm(ctx context.Context, dockerCLI command.Cli, opts *rmOptions) error { |
| 73 | apiClient := dockerCLI.Client() |
| 74 | errChan := parallelOperation(ctx, opts.containers, func(ctx context.Context, ctrID string) error { |
| 75 | ctrID = strings.Trim(ctrID, "/") |
| 76 | if ctrID == "" { |
| 77 | return errors.New("container name cannot be empty") |
| 78 | } |
| 79 | _, err := apiClient.ContainerRemove(ctx, ctrID, client.ContainerRemoveOptions{ |
| 80 | RemoveVolumes: opts.rmVolumes, |
| 81 | RemoveLinks: opts.rmLink, |
| 82 | Force: opts.force, |
| 83 | }) |
| 84 | return err |
| 85 | }) |
| 86 | |
| 87 | var errs []error |
| 88 | for _, name := range opts.containers { |
| 89 | if err := <-errChan; err != nil { |
| 90 | if opts.force && errdefs.IsNotFound(err) { |
| 91 | _, _ = fmt.Fprintln(dockerCLI.Err(), err) |
| 92 | continue |
| 93 | } |
| 94 | errs = append(errs, err) |
| 95 | continue |
| 96 | } |
| 97 | _, _ = fmt.Fprintln(dockerCLI.Out(), name) |
| 98 | } |
| 99 | return errors.Join(errs...) |
| 100 | } |
no test coverage detected
searching dependent graphs…