(ctx context.Context, dockerCLI command.Cli, networks []string, opts *removeOptions)
| 44 | "ingress networks will be impaired.\nAre you sure you want to continue?" |
| 45 | |
| 46 | func runRemove(ctx context.Context, dockerCLI command.Cli, networks []string, opts *removeOptions) error { |
| 47 | apiClient := dockerCLI.Client() |
| 48 | |
| 49 | status := 0 |
| 50 | |
| 51 | for _, name := range networks { |
| 52 | res, err := apiClient.NetworkInspect(ctx, name, client.NetworkInspectOptions{}) |
| 53 | if err == nil && res.Network.Ingress { |
| 54 | r, err := prompt.Confirm(ctx, dockerCLI.In(), dockerCLI.Out(), ingressWarning) |
| 55 | if err != nil { |
| 56 | return err |
| 57 | } |
| 58 | if !r { |
| 59 | continue |
| 60 | } |
| 61 | } |
| 62 | _, err = apiClient.NetworkRemove(ctx, name, client.NetworkRemoveOptions{}) |
| 63 | if err != nil { |
| 64 | if opts.force && errdefs.IsNotFound(err) { |
| 65 | continue |
| 66 | } |
| 67 | _, _ = fmt.Fprintln(dockerCLI.Err(), err) |
| 68 | status = 1 |
| 69 | continue |
| 70 | } |
| 71 | _, _ = fmt.Fprintln(dockerCLI.Out(), name) |
| 72 | } |
| 73 | |
| 74 | if status != 0 { |
| 75 | return cli.StatusError{StatusCode: status, Status: "exit status " + strconv.Itoa(status)} |
| 76 | } |
| 77 | return nil |
| 78 | } |
no test coverage detected
searching dependent graphs…