update-context: Automatically set the context as current/active in kubeconfig

pull/9281/head
Predrag Rogic 2020-09-21 00:06:15 +01:00
parent 38da8de55d
commit 9fbd2e94bd
1 changed files with 6 additions and 0 deletions

View File

@ -45,5 +45,11 @@ var updateContextCmd = &cobra.Command{
} else {
out.T(style.Meh, `No changes required for the "{{.context}}" context`, out.V{"context": cname})
}
if err := kubeconfig.SetCurrentContext(cname, kubeconfig.PathFromEnv()); err != nil {
out.ErrT(style.Sad, `Error while setting kubectl current context: {{.error}}`, out.V{"error": err})
} else {
out.T(style.Kubectl, `Current context is "{{.context}}"`, out.V{"context": cname})
}
},
}