Skip to content

Commit b69f070

Browse files
committed
Fixed an ArgumentNullException caused by a missing "cluster" configuration section. Now the error is more user friendly
1 parent 29a3dac commit b69f070

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/KubernetesClientConfiguration.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ private void Initialize(K8SConfiguration k8SConfig, string currentContext = null
128128
this.CurrentContext = activeContext.Name;
129129
}
130130

131+
if (k8SConfig.Clusters == null)
132+
{
133+
throw new KubeConfigException($"clusters not found for current-context :{activeContext} in kubeconfig");
134+
}
135+
131136
var clusterDetails = k8SConfig.Clusters.FirstOrDefault(c => c.Name.Equals(activeContext.ContextDetails.Cluster, StringComparison.OrdinalIgnoreCase));
132137
if (clusterDetails?.ClusterEndpoint != null)
133138
{

0 commit comments

Comments
 (0)