From 273f99b293cf33665de7225b8c91ac6d2573f87b Mon Sep 17 00:00:00 2001 From: Alexander Matyushentsev Date: Mon, 16 Jul 2018 23:54:12 +0300 Subject: [PATCH] Issue #414 - fix nil pointer in 'argocd cluster add' (#416) * Issue #414 - fix nil pointer in 'argocd cluster add' * Add missing nil check --- cmd/argocd/commands/cluster.go | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 = "*"