Skip to content

Commit

Permalink
add an new flag to stop command --keep-context-active
Browse files Browse the repository at this point in the history
  • Loading branch information
medyagh committed Aug 20, 2020
1 parent b27dbc0 commit 94d4f89
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/minikube/cmd/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
)

var stopAll bool
var keepActive bool

// stopCmd represents the stop command
var stopCmd = &cobra.Command{
Expand All @@ -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)
Expand Down Expand Up @@ -111,8 +113,10 @@ func stopProfile(profile string) int {
out.WarningT("Unable to kill mount process: {{.error}}", out.V{"error": err})
}

if err := kubeconfig.UnsetCurrentContext(profile, kubeconfig.PathFromEnv()); err != nil {
exit.WithError("update config", err)
if !keepActive {
if err := kubeconfig.UnsetCurrentContext(profile, kubeconfig.PathFromEnv()); err != nil {
exit.WithError("update config", err)
}
}

return stoppedNodes
Expand Down

0 comments on commit 94d4f89

Please sign in to comment.