diff --git a/src/common/cluster-store_spec.ts b/src/common/cluster-store_spec.ts index fd2e6d94a5..3bc87a7cd8 100644 --- a/src/common/cluster-store_spec.ts +++ b/src/common/cluster-store_spec.ts @@ -46,6 +46,7 @@ describe("for an empty config", () => { clusterStore.storeCluster(cluster); const storedCluster = clusterStore.getCluster(cluster.id); expect(storedCluster.kubeConfigPath).toBe(cluster.kubeConfigPath) + expect(storedCluster.contextName).toBe(cluster.contextName) expect(storedCluster.preferences.icon).toBe(cluster.preferences.icon) expect(storedCluster.preferences.terminalCWD).toBe(cluster.preferences.terminalCWD) expect(storedCluster.id).toBe(cluster.id) diff --git a/src/main/context-handler.ts b/src/main/context-handler.ts index 2e9dcb64a3..ad0bd85019 100644 --- a/src/main/context-handler.ts +++ b/src/main/context-handler.ts @@ -35,7 +35,7 @@ export class ContextHandler { this.id = cluster.id this.cluster = cluster - this.clusterUrl = url.parse(cluster.apiUrl) //url.parse(kc.getCurrentCluster().server) + this.clusterUrl = url.parse(cluster.apiUrl) this.contextName = cluster.contextName; this.defaultNamespace = kc.getContextObject(cluster.contextName).namespace this.url = `http://${this.id}.localhost:${cluster.port}/` diff --git a/src/migrations/cluster-store/3.6.0-beta.1.ts b/src/migrations/cluster-store/3.6.0-beta.1.ts index 0ef3631da3..d4c867ffbd 100644 --- a/src/migrations/cluster-store/3.6.0-beta.1.ts +++ b/src/migrations/cluster-store/3.6.0-beta.1.ts @@ -16,18 +16,20 @@ export function migration(store: any) { console.log("num clusters to migrate: ", storedClusters.length) for (const cluster of storedClusters ) { - // TODO Should probably guard this, not to make the whole migration fail if one cluster fails!? - - // take the embedded kubeconfig and dump it into a file - const kubeConfigFile = writeEmbeddedKubeConfig(cluster.id, cluster.kubeConfig) - cluster.kubeConfigPath = kubeConfigFile + try { + // take the embedded kubeconfig and dump it into a file + const kubeConfigFile = writeEmbeddedKubeConfig(cluster.id, cluster.kubeConfig) + cluster.kubeConfigPath = kubeConfigFile - const kc = new KubeConfig() - kc.loadFromFile(cluster.kubeConfigPath) - cluster.contextName = kc.getCurrentContext() + const kc = new KubeConfig() + kc.loadFromFile(cluster.kubeConfigPath) + cluster.contextName = kc.getCurrentContext() - delete cluster.kubeConfig - clusters.push(cluster) + delete cluster.kubeConfig + clusters.push(cluster) + } catch(error) { + console.error("failed to migrate kubeconfig for cluster:", cluster.id) + } } // "overwrite" the cluster configs