Skip to content

Commit

Permalink
fix rename
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny0826 committed Dec 3, 2019
1 parent 1b327f5 commit 08dc225
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions cmd/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,19 @@ kubecm rename -n dev -c
num := SelectUI(kubeItems, "Select The Rename Kube Context")
kubeName := kubeItems[num].Name
rename := InputStr(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 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 {
cover, _ = cmd.Flags().GetBool("cover")
Expand Down

0 comments on commit 08dc225

Please sign in to comment.