From 69d95cc847e937b447eba6ea91f4aa8bcecab7f9 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Thu, 19 May 2022 17:17:28 +0200 Subject: [PATCH] create: warn if instance name already exists as context builder Signed-off-by: CrazyMax --- commands/create.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/commands/create.go b/commands/create.go index f946b903..2a9c1296 100644 --- a/commands/create.go +++ b/commands/create.go @@ -101,6 +101,19 @@ func runCreate(dockerCli command.Cli, in createOptions, args []string) error { } } + if !in.actionLeave && !in.actionAppend { + contexts, err := dockerCli.ContextStore().List() + if err != nil { + return err + } + for _, c := range contexts { + if c.Name == name { + logrus.Warnf("instance name %q already exists as context builder", name) + break + } + } + } + ng, err := txn.NodeGroupByName(name) if err != nil { if os.IsNotExist(errors.Cause(err)) {