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 {
|
export interface ClusterBaseInfo {
|
||||||
id: string;
|
id: string;
|
||||||
|
kubeConfig?: string;
|
||||||
kubeConfigPath: string;
|
kubeConfigPath: string;
|
||||||
contextName: string;
|
contextName: string;
|
||||||
preferences?: ClusterPreferences;
|
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 { app } from "electron"
|
||||||
import { ensureDirSync } from "fs-extra"
|
import { migration } from "../migration-wrapper";
|
||||||
import * as path from "path"
|
import { ensureDirSync } from "fs-extra"
|
||||||
import { KubeConfig } from "@kubernetes/client-node";
|
import { KubeConfig } from "@kubernetes/client-node";
|
||||||
import { writeEmbeddedKubeConfig } from "../../common/utils/kubeconfig"
|
import { writeEmbeddedKubeConfig } from "../../common/utils/kubeconfig"
|
||||||
|
import { ClusterBaseInfo } from "../../main/cluster";
|
||||||
|
|
||||||
export function migration(store: any) {
|
export default migration({
|
||||||
console.log("CLUSTER STORE, MIGRATION: 3.6.0-beta.1");
|
version: "3.6.0-beta.1",
|
||||||
const clusters: any[] = []
|
run(store, log: (...args: any[]) => void) {
|
||||||
|
const migratingClusters: ClusterBaseInfo[] = []
|
||||||
|
|
||||||
const kubeConfigBase = path.join(app.getPath("userData"), "kubeconfigs")
|
const kubeConfigBase = path.join(app.getPath("userData"), "kubeconfigs")
|
||||||
ensureDirSync(kubeConfigBase)
|
ensureDirSync(kubeConfigBase)
|
||||||
const storedClusters = store.get("clusters") as any[]
|
const storedClusters: ClusterBaseInfo[] = store.get("clusters")
|
||||||
if (!storedClusters) return
|
if (!storedClusters) return
|
||||||
|
|
||||||
console.log("num clusters to migrate: ", storedClusters.length)
|
log("Number of clusters to migrate: ", storedClusters.length)
|
||||||
for (const cluster of storedClusters ) {
|
for (const cluster of storedClusters) {
|
||||||
try {
|
try {
|
||||||
// take the embedded kubeconfig and dump it into a file
|
// take the embedded kubeconfig and dump it into a file
|
||||||
const kubeConfigFile = writeEmbeddedKubeConfig(cluster.id, cluster.kubeConfig)
|
cluster.kubeConfigPath = writeEmbeddedKubeConfig(cluster.id, cluster.kubeConfig)
|
||||||
cluster.kubeConfigPath = kubeConfigFile
|
|
||||||
|
|
||||||
const kc = new KubeConfig()
|
const kc = new KubeConfig()
|
||||||
kc.loadFromFile(cluster.kubeConfigPath)
|
kc.loadFromFile(cluster.kubeConfigPath)
|
||||||
cluster.contextName = kc.getCurrentContext()
|
cluster.contextName = kc.getCurrentContext()
|
||||||
|
|
||||||
delete cluster.kubeConfig
|
delete cluster.kubeConfig
|
||||||
clusters.push(cluster)
|
migratingClusters.push(cluster)
|
||||||
} catch(error) {
|
} catch (error) {
|
||||||
console.error("failed to migrate kubeconfig for cluster:", cluster.id)
|
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 version260Beta3 from "./2.6.0-beta.3"
|
||||||
import version270Beta0 from "./2.7.0-beta.0"
|
import version270Beta0 from "./2.7.0-beta.0"
|
||||||
import version270Beta1 from "./2.7.0-beta.1"
|
import version270Beta1 from "./2.7.0-beta.1"
|
||||||
|
import version360Beta1 from "./3.6.0-beta.1"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
...version200Beta2,
|
...version200Beta2,
|
||||||
@ -14,4 +15,5 @@ export default {
|
|||||||
...version260Beta3,
|
...version260Beta3,
|
||||||
...version270Beta0,
|
...version270Beta0,
|
||||||
...version270Beta1,
|
...version270Beta1,
|
||||||
|
...version360Beta1,
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user