Skip to content

Commit

Permalink
fix bug rename
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny0826 committed Dec 3, 2019
1 parent 08dc225 commit 570be57
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions cmd/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Binary file modified dosc/Interaction.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 570be57

Please sign in to comment.