add an new flag to stop command --keep-context-active

pull/9044/head
Medya Gh 2020-08-20 12:01:15 -07:00
parent 344a5be6d5
commit e9cfbd0098
1 changed files with 6 additions and 2 deletions

View File

@ -38,6 +38,7 @@ import (
)
var stopAll bool
var keepActive bool
// stopCmd represents the stop command
var stopCmd = &cobra.Command{
@ -51,6 +52,7 @@ itself, leaving all files intact. The cluster can be started again with the "sta
func init() {
stopCmd.Flags().BoolVar(&stopAll, "all", false, "Set flag to stop all profiles (clusters)")
stopCmd.Flags().BoolVar(&keepActive, "keep-context-active", false, "keep the kube-context active after cluster is stopped. Defaults to false.")
if err := viper.GetViper().BindPFlags(stopCmd.Flags()); err != nil {
exit.WithError("unable to bind flags", err)
@ -111,9 +113,11 @@ func stopProfile(profile string) int {
out.WarningT("Unable to kill mount process: {{.error}}", out.V{"error": err})
}
if !keepActive {
if err := kubeconfig.UnsetCurrentContext(profile, kubeconfig.PathFromEnv()); err != nil {
exit.WithError("update config", err)
}
}
return stoppedNodes
}