MCPcopy Index your code
hub / github.com/docker/cli / runRemove

Function runRemove

cli/command/network/remove.go:46–78  ·  view source on GitHub ↗
(ctx context.Context, dockerCLI command.Cli, networks []string, opts *removeOptions)

Source from the content-addressed store, hash-verified

44 "ingress networks will be impaired.\nAre you sure you want to continue?"
45
46func 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}

Callers 1

newRemoveCommandFunction · 0.70

Calls 6

ClientMethod · 0.65
InMethod · 0.65
OutMethod · 0.65
ErrMethod · 0.65
NetworkInspectMethod · 0.45
NetworkRemoveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…