runRemove removes one or more contexts.
(dockerCLI command.Cli, opts removeOptions, names []string)
| 34 | |
| 35 | // runRemove removes one or more contexts. |
| 36 | func 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 | |
| 51 | func doRemove(dockerCli command.Cli, name string, isCurrent, force bool) error { |
| 52 | if isCurrent { |
searching dependent graphs…