Fix config clusters index in CurrentContextCluster()

Config.Clusters should be indexed only by "simple" cluster names
(without _ephemeral or _target postfixes).  This fixes an index
that indexed by the "full" cluster name defined in the kubeconfig,
in some cases resulting in a nil pointer dereference.

Change-Id: Ic7a4b46419354d5755ccea58ff73c5fbbc4d9658
This commit is contained in:
Matt McEuen 2020-01-17 17:00:11 -06:00
parent e2297e429d
commit d0ca82d624

View File

@ -568,8 +568,10 @@ func (c *Config) CurrentContextCluster() (*Cluster, error) {
if err != nil {
return nil, err
}
clusterName := NewClusterComplexName()
clusterName.FromName(currentContext.KubeContext().Cluster)
return c.Clusters[currentContext.KubeContext().Cluster].ClusterTypes[currentContext.ClusterType()], nil
return c.Clusters[clusterName.ClusterName()].ClusterTypes[currentContext.ClusterType()], nil
}
func (c *Config) CurrentContextAuthInfo() (*AuthInfo, error) {