diff --git a/cmd/argocd/commands/cluster.go b/cmd/argocd/commands/cluster.go index 5930ec8cff..16d037785a 100644 --- a/cmd/argocd/commands/cluster.go +++ b/cmd/argocd/commands/cluster.go @@ -109,9 +109,20 @@ func printKubeContexts(ca clientcmd.ConfigAccess) { } sort.Strings(contextNames) + if config.Clusters == nil { + return + } + for _, name := range contextNames { + // ignore malformed kube config entries context := config.Contexts[name] + if context == nil { + continue + } cluster := config.Clusters[context.Cluster] + if cluster == nil { + continue + } prefix := " " if config.CurrentContext == name { prefix = "*"