From f676429e3ef0ef86db6da00cda15e3e925eddf05 Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Thu, 25 Feb 2021 16:21:25 +0200 Subject: [PATCH 1/2] Update validateKubeConfig in-code documentation Signed-off-by: Lauri Nevala --- src/common/kube-helpers.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/common/kube-helpers.ts b/src/common/kube-helpers.ts index 3cf4fda6de..c2a2a8df93 100644 --- a/src/common/kube-helpers.ts +++ b/src/common/kube-helpers.ts @@ -157,8 +157,7 @@ export function getNodeWarningConditions(node: V1Node) { } /** - * Validates Context, User and Cluster sructs in given kubeconfig. Additionally this will validate - * the command passed to the exec substructure. + * Checks if `config` has valid `Context`, `User`, `Cluster`, and `exec` fields (if present when required) */ export function validateKubeConfig (config: KubeConfig, contextName: string, validationOpts: KubeConfigValidationOpts = {}) { // we only receive a single context, cluster & user object here so lets validate them as this From ed6e00798dae83e9902ddae30a14ace5a6849b42 Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Mon, 1 Mar 2021 11:56:30 +0200 Subject: [PATCH 2/2] Remove isDead property Signed-off-by: Lauri Nevala --- src/common/cluster-store.ts | 4 ++-- src/main/cluster.ts | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/common/cluster-store.ts b/src/common/cluster-store.ts index 2eae7da6a8..6bf932f0f4 100644 --- a/src/common/cluster-store.ts +++ b/src/common/cluster-store.ts @@ -323,7 +323,7 @@ export class ClusterStore extends BaseStore { } else { cluster = new Cluster(clusterModel); - if (!cluster.isManaged && !cluster.isDead) { + if (!cluster.isManaged && cluster.apiUrl) { cluster.enabled = true; } } @@ -337,7 +337,7 @@ export class ClusterStore extends BaseStore { } }); - this.activeCluster = newClusters.has(activeCluster) && newClusters.get(activeCluster).enabled ? activeCluster : null; + this.activeCluster = newClusters.get(activeCluster)?.enabled ? activeCluster : null; this.clusters.replace(newClusters); this.removedClusters.replace(removedClusters); } diff --git a/src/main/cluster.ts b/src/main/cluster.ts index 8e7bc507e2..93083cf7cb 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -77,7 +77,6 @@ export class Cluster implements ClusterModel, ClusterState { * If extension sets this it needs to also mark cluster as enabled on activate (or when added to a store) */ public ownerRef: string; - public isDead = false; protected kubeconfigManager: KubeconfigManager; protected eventDisposers: Function[] = []; protected activated = false; @@ -267,7 +266,6 @@ export class Cluster implements ClusterModel, ClusterState { } catch(err) { logger.error(err); logger.error(`[CLUSTER] Failed to load kubeconfig for the cluster '${this.name || this.contextName}' (context: ${this.contextName}, kubeconfig: ${this.kubeConfigPath}).`); - this.isDead = true; } }