|
|
@ -43,31 +43,37 @@ func runRm(dockerCli command.Cli, in rmOptions) error {
|
|
|
|
return rmAllInactive(ctx, txn, dockerCli, in)
|
|
|
|
return rmAllInactive(ctx, txn, dockerCli, in)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ng *store.NodeGroup
|
|
|
|
if in.builder != "" {
|
|
|
|
if in.builder != "" {
|
|
|
|
ng, err := storeutil.GetNodeGroup(txn, dockerCli, in.builder)
|
|
|
|
ng, err = storeutil.GetNodeGroup(txn, dockerCli, in.builder)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err1 := rm(ctx, dockerCli, in, ng)
|
|
|
|
} else {
|
|
|
|
if err := txn.Remove(ng.Name); err != nil {
|
|
|
|
ng, err = storeutil.GetCurrentInstance(txn, dockerCli)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return err1
|
|
|
|
}
|
|
|
|
|
|
|
|
if ng == nil {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ng, err := storeutil.GetCurrentInstance(txn, dockerCli)
|
|
|
|
ctxbuilders, err := dockerCli.ContextStore().List()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ng != nil {
|
|
|
|
for _, cb := range ctxbuilders {
|
|
|
|
|
|
|
|
if ng.Driver == "docker" && len(ng.Nodes) == 1 && ng.Nodes[0].Endpoint == cb.Name {
|
|
|
|
|
|
|
|
return errors.Errorf("context builder cannot be removed, run `docker context rm %s` to remove this context", cb.Name)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
err1 := rm(ctx, dockerCli, in, ng)
|
|
|
|
err1 := rm(ctx, dockerCli, in, ng)
|
|
|
|
if err := txn.Remove(ng.Name); err != nil {
|
|
|
|
if err := txn.Remove(ng.Name); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return err1
|
|
|
|
return err1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func rmCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
|
|
|
|
func rmCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
|
|
|
|