Skip to content

Commit

Permalink
Merge pull request #9044 from medyagh/stop_keep_contex
Browse files Browse the repository at this point in the history
add an new flag to stop command --keep-context-active
  • Loading branch information
medyagh authored Aug 21, 2020
2 parents e91d98b + 200fddd commit ba96f29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 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
5 changes: 3 additions & 2 deletions site/content/en/docs/commands/stop.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ minikube stop [flags]
### Options

```
--all Set flag to stop all profiles (clusters)
-h, --help help for stop
--all Set flag to stop all profiles (clusters)
-h, --help help for stop
--keep-context-active keep the kube-context active after cluster is stopped. Defaults to false.
```

### Options inherited from parent commands
Expand Down

0 comments on commit ba96f29

Please sign in to comment.