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

Function runRemove

cli/command/context/remove.go:36–49  ·  view source on GitHub ↗

runRemove removes one or more contexts.

(dockerCLI command.Cli, opts removeOptions, names []string)

Source from the content-addressed store, hash-verified

34
35// runRemove removes one or more contexts.
36func runRemove(dockerCLI command.Cli, opts removeOptions, names []string) error {
37 var errs []error
38 currentCtx := dockerCLI.CurrentContext()
39 for _, name := range names {
40 if name == "default" {
41 errs = append(errs, errors.New(`context "default" cannot be removed`))
42 } else if err := doRemove(dockerCLI, name, name == currentCtx, opts.force); err != nil {
43 errs = append(errs, err)
44 } else {
45 _, _ = fmt.Fprintln(dockerCLI.Out(), name)
46 }
47 }
48 return errors.Join(errs...)
49}
50
51func doRemove(dockerCli command.Cli, name string, isCurrent, force bool) error {
52 if isCurrent {

Callers 6

newRemoveCommandFunction · 0.70
TestRemoveFunction · 0.70
TestRemoveNotAContextFunction · 0.70
TestRemoveCurrentFunction · 0.70
TestRemoveCurrentForceFunction · 0.70
TestRemoveDefaultFunction · 0.70

Calls 3

doRemoveFunction · 0.85
CurrentContextMethod · 0.65
OutMethod · 0.65

Tested by 5

TestRemoveFunction · 0.56
TestRemoveNotAContextFunction · 0.56
TestRemoveCurrentFunction · 0.56
TestRemoveCurrentForceFunction · 0.56
TestRemoveDefaultFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…