Merge pull request #9044 from medyagh/stop_keep_contex
add an new flag to stop command --keep-context-activepull/9052/head
commit
ba96f292d8
|
@ -38,6 +38,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var stopAll bool
|
var stopAll bool
|
||||||
|
var keepActive bool
|
||||||
|
|
||||||
// stopCmd represents the stop command
|
// stopCmd represents the stop command
|
||||||
var stopCmd = &cobra.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() {
|
func init() {
|
||||||
|
|
||||||
stopCmd.Flags().BoolVar(&stopAll, "all", false, "Set flag to stop all profiles (clusters)")
|
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 {
|
if err := viper.GetViper().BindPFlags(stopCmd.Flags()); err != nil {
|
||||||
exit.WithError("unable to bind flags", err)
|
exit.WithError("unable to bind flags", err)
|
||||||
|
@ -111,8 +113,10 @@ func stopProfile(profile string) int {
|
||||||
out.WarningT("Unable to kill mount process: {{.error}}", out.V{"error": err})
|
out.WarningT("Unable to kill mount process: {{.error}}", out.V{"error": err})
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := kubeconfig.UnsetCurrentContext(profile, kubeconfig.PathFromEnv()); err != nil {
|
if !keepActive {
|
||||||
exit.WithError("update config", err)
|
if err := kubeconfig.UnsetCurrentContext(profile, kubeconfig.PathFromEnv()); err != nil {
|
||||||
|
exit.WithError("update config", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return stoppedNodes
|
return stoppedNodes
|
||||||
|
|
|
@ -22,8 +22,9 @@ minikube stop [flags]
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
--all Set flag to stop all profiles (clusters)
|
--all Set flag to stop all profiles (clusters)
|
||||||
-h, --help help for stop
|
-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
|
### Options inherited from parent commands
|
||||||
|
|
Loading…
Reference in New Issue