Skip to content

Commit

Permalink
fix(kube): fix GetAllContextsClients not working in in-cluster mode
Browse files Browse the repository at this point in the history
Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed May 24, 2022
1 parent 01abc7d commit 802c1b0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ func GetAllContextsClients(opts GetAllContextsClientsOptions) ([]*ContextClient,
var outOfClusterErr error
contexts, outOfClusterErr := getOutOfClusterContextsClients(opts.ConfigPath, opts.ConfigDataBase64, opts.ConfigPathMergeList)
// return if contexts are loaded successfully
if contexts != nil {
if len(contexts) > 0 {
return contexts, nil
}

if hasInClusterConfig() {
contextClient, err := getInClusterContextClient()
if err != nil {
Expand Down Expand Up @@ -261,7 +262,7 @@ func getOutOfClusterConfig(context, configPath, configDataBase64 string, configP
}

func getOutOfClusterContextsClients(configPath, configDataBase64 string, configPathMergeList []string) ([]*ContextClient, error) {
res := make([]*ContextClient, 0)
var res []*ContextClient

configData, err := parseConfigDataBase64(configDataBase64)
if err != nil {
Expand Down

0 comments on commit 802c1b0

Please sign in to comment.