diff --git a/cmd/root.go b/cmd/root.go index 7c1785ef03a4630f0f63b3b3714e02b99cf34470..5d9b70a2828cd285a08d82ed149a875cc6aaee68 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -157,7 +157,10 @@ func resolveContext(context *string) (server, namespace string, err error) { } log.Infof("Using context '%s'", ctxName) - cluster := rawConfig.Clusters[ctx.Cluster] + cluster, exists := rawConfig.Clusters[ctx.Cluster] + if !exists { + return "", "", fmt.Errorf("No cluster with name '%s' exists", ctx.Cluster) + } return cluster.Server, ctx.Namespace, nil }