Co-authored-by: Clément Loiselet <clement.loiselet@cbp-group.com>mine
parent
694159b857
commit
24e244ca82
|
|
@ -357,6 +357,8 @@ K9s uses aliases to navigate most K8s resources.
|
|||
currentContext: minikube
|
||||
# Indicates the current kube cluster. Defaults to current context cluster
|
||||
currentCluster: minikube
|
||||
# KeepMissingClusters will keep clusters in the config if they are missing from the current kubeconfig file. Default false
|
||||
KeepMissingClusters: false
|
||||
# Persists per cluster preferences for favorite namespaces and view.
|
||||
clusters:
|
||||
coolio:
|
||||
|
|
|
|||
|
|
@ -297,6 +297,7 @@ var expectedConfig = `k9s:
|
|||
showTime: false
|
||||
currentContext: blee
|
||||
currentCluster: blee
|
||||
keepMissingClusters: false
|
||||
clusters:
|
||||
blee:
|
||||
namespace:
|
||||
|
|
@ -397,6 +398,7 @@ var resetConfig = `k9s:
|
|||
showTime: false
|
||||
currentContext: blee
|
||||
currentCluster: blee
|
||||
keepMissingClusters: false
|
||||
clusters:
|
||||
blee:
|
||||
namespace:
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ type K9s struct {
|
|||
Logger *Logger `yaml:"logger"`
|
||||
CurrentContext string `yaml:"currentContext"`
|
||||
CurrentCluster string `yaml:"currentCluster"`
|
||||
KeepMissingClusters bool `yaml:"keepMissingClusters"`
|
||||
Clusters map[string]*Cluster `yaml:"clusters,omitempty"`
|
||||
Thresholds Threshold `yaml:"thresholds"`
|
||||
ScreenDumpDir string `yaml:"screenDumpDir"`
|
||||
|
|
@ -206,9 +207,17 @@ func (k *K9s) validateClusters(c client.Connection, ks KubeSettings) {
|
|||
}
|
||||
for key, cluster := range k.Clusters {
|
||||
cluster.Validate(c, ks)
|
||||
// if the cluster is defined in the $KUBECONFIG file, keep it in the k9s config file
|
||||
if _, ok := cc[key]; ok {
|
||||
continue
|
||||
}
|
||||
|
||||
// if we asked to keep the clusters in the config file
|
||||
if k.KeepMissingClusters {
|
||||
continue
|
||||
}
|
||||
|
||||
// else remove it from the k9s config file
|
||||
if k.CurrentCluster == key {
|
||||
k.CurrentCluster = ""
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue