Fix accessing nil map (#1996)

Co-authored-by: julien.demais.e <julien.demais.e@thalesdigital.io>
mine
croustiPoulet 2023-03-17 06:02:47 +01:00 committed by GitHub
parent ab9f960788
commit 2955e2251f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -54,6 +54,9 @@ func (k *K9s) CurrentContextDir() string {
// ActivateCluster initializes the active cluster is not present.
func (k *K9s) ActivateCluster(ns string) {
if k.Clusters == nil {
k.Clusters = map[string]*Cluster{}
}
if _, ok := k.Clusters[k.CurrentCluster]; ok {
return
}