1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2020-07-03 11:51:19 +03:00
parent fc0632a204
commit 9089bfbc01
3 changed files with 14 additions and 11 deletions

View File

@ -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)

View File

@ -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}/`

View File

@ -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