mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
master-merge fixes
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
f9c0c5d825
commit
c9fb015bcf
@ -19,6 +19,7 @@ enum ClusterStatus {
|
||||
|
||||
export interface ClusterBaseInfo {
|
||||
id: string;
|
||||
kubeConfig?: string;
|
||||
kubeConfigPath: string;
|
||||
contextName: string;
|
||||
preferences?: ClusterPreferences;
|
||||
|
||||
@ -1,39 +1,43 @@
|
||||
// move embedded kubeconfig into separate file and add reference to it to cluster settings
|
||||
// Move embedded kubeconfig into separate file and add reference to it to cluster settings
|
||||
|
||||
import path from "path"
|
||||
import { app } from "electron"
|
||||
import { ensureDirSync } from "fs-extra"
|
||||
import * as path from "path"
|
||||
import { migration } from "../migration-wrapper";
|
||||
import { ensureDirSync } from "fs-extra"
|
||||
import { KubeConfig } from "@kubernetes/client-node";
|
||||
import { writeEmbeddedKubeConfig } from "../../common/utils/kubeconfig"
|
||||
import { ClusterBaseInfo } from "../../main/cluster";
|
||||
|
||||
export function migration(store: any) {
|
||||
console.log("CLUSTER STORE, MIGRATION: 3.6.0-beta.1");
|
||||
const clusters: any[] = []
|
||||
export default migration({
|
||||
version: "3.6.0-beta.1",
|
||||
run(store, log: (...args: any[]) => void) {
|
||||
const migratingClusters: ClusterBaseInfo[] = []
|
||||
|
||||
const kubeConfigBase = path.join(app.getPath("userData"), "kubeconfigs")
|
||||
ensureDirSync(kubeConfigBase)
|
||||
const storedClusters = store.get("clusters") as any[]
|
||||
if (!storedClusters) return
|
||||
const kubeConfigBase = path.join(app.getPath("userData"), "kubeconfigs")
|
||||
ensureDirSync(kubeConfigBase)
|
||||
const storedClusters: ClusterBaseInfo[] = store.get("clusters")
|
||||
if (!storedClusters) return
|
||||
|
||||
console.log("num clusters to migrate: ", storedClusters.length)
|
||||
for (const cluster of storedClusters ) {
|
||||
try {
|
||||
// take the embedded kubeconfig and dump it into a file
|
||||
const kubeConfigFile = writeEmbeddedKubeConfig(cluster.id, cluster.kubeConfig)
|
||||
cluster.kubeConfigPath = kubeConfigFile
|
||||
log("Number of clusters to migrate: ", storedClusters.length)
|
||||
for (const cluster of storedClusters) {
|
||||
try {
|
||||
// take the embedded kubeconfig and dump it into a file
|
||||
cluster.kubeConfigPath = writeEmbeddedKubeConfig(cluster.id, cluster.kubeConfig)
|
||||
|
||||
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)
|
||||
} catch(error) {
|
||||
console.error("failed to migrate kubeconfig for cluster:", cluster.id)
|
||||
delete cluster.kubeConfig
|
||||
migratingClusters.push(cluster)
|
||||
} catch (error) {
|
||||
log(`Failed to migrate Kubeconfig for cluster "${cluster.id}"`, error)
|
||||
}
|
||||
}
|
||||
|
||||
// "overwrite" the cluster configs
|
||||
if (migratingClusters.length > 0) {
|
||||
store.set("clusters", migratingClusters)
|
||||
}
|
||||
}
|
||||
|
||||
// "overwrite" the cluster configs
|
||||
if (clusters.length > 0) {
|
||||
store.set("clusters", clusters)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -6,6 +6,7 @@ import version260Beta2 from "./2.6.0-beta.2"
|
||||
import version260Beta3 from "./2.6.0-beta.3"
|
||||
import version270Beta0 from "./2.7.0-beta.0"
|
||||
import version270Beta1 from "./2.7.0-beta.1"
|
||||
import version360Beta1 from "./3.6.0-beta.1"
|
||||
|
||||
export default {
|
||||
...version200Beta2,
|
||||
@ -14,4 +15,5 @@ export default {
|
||||
...version260Beta3,
|
||||
...version270Beta0,
|
||||
...version270Beta1,
|
||||
...version360Beta1,
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user