diff --git a/cmd/rename.go b/cmd/rename.go index fa80b6aa..ae4b9435 100644 --- a/cmd/rename.go +++ b/cmd/rename.go @@ -53,19 +53,27 @@ kubecm rename -n dev -c num := SelectUI(kubeItems, "Select The Rename Kube Context") kubeName := kubeItems[num].Name rename := InputStr(kubeName) - if rename != kubeName{ - if obj, ok := config.Contexts[kubeName]; ok { - config.Contexts[rename] = obj - delete(config.Contexts, kubeName) - if config.CurrentContext == kubeName { - config.CurrentContext = rename + if rename != kubeName { + if _, ok := config.Contexts[rename]; ok { + log.Printf("Name: %s already exists", rename) + os.Exit(-1) + } else { + if obj, ok := config.Contexts[kubeName]; ok { + config.Contexts[rename] = obj + delete(config.Contexts, kubeName) + if config.CurrentContext == kubeName { + config.CurrentContext = rename + } + } + err = ModifyKubeConfig(config) + if err != nil { + Error.Println(err) + os.Exit(1) } } - err = ModifyKubeConfig(config) - if err != nil { - Error.Println(err) - os.Exit(1) - } + } else { + log.Printf("No name: %s changes", rename) + os.Exit(-1) } } else { cover, _ = cmd.Flags().GetBool("cover") diff --git a/dosc/Interaction.gif b/dosc/Interaction.gif index fdba039e..a47ef04d 100644 Binary files a/dosc/Interaction.gif and b/dosc/Interaction.gif differ