mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
1 parent
2a818601f9
commit
5b98674d80
16 files changed
+286
-96
No files matched your search
@@ -4,13 +4,12 @@ import path from "path"
|
||||
import { app, remote } from "electron"
|
||||
import { migration } from "../migration-wrapper";
|
||||
import { ensureDirSync } from "fs-extra"
|
||||
import { writeEmbeddedKubeConfig } from "../../common/utils/kubeconfig"
|
||||
import { ClusterModel } from "../../common/cluster-store";
|
||||
import { loadConfig } from "../../main/k8s";
|
||||
import { loadConfig, saveConfigToAppFiles } from "../../common/kube-helpers";
|
||||
|
||||
export default migration({
|
||||
version: "3.6.0-beta.1",
|
||||
run(store, log: (...args: any[]) => void) {
|
||||
run(store, printLog) {
|
||||
const migratedClusters: ClusterModel[] = []
|
||||
const storedClusters: ClusterModel[] = store.get("clusters");
|
||||
const kubeConfigBase = path.join((app || remote.app).getPath("userData"), "kubeconfigs")
|
||||
@@ -18,16 +17,16 @@ export default migration({
|
||||
if (!storedClusters) return;
|
||||
ensureDirSync(kubeConfigBase);
|
||||
|
||||
log("Number of clusters to migrate: ", storedClusters.length)
|
||||
printLog("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)
|
||||
cluster.kubeConfigPath = saveConfigToAppFiles(cluster.id, cluster.kubeConfig)
|
||||
cluster.contextName = loadConfig(cluster.kubeConfigPath).getCurrentContext();
|
||||
delete cluster.kubeConfig;
|
||||
migratedClusters.push(cluster)
|
||||
} catch (error) {
|
||||
log(`Failed to migrate Kubeconfig for cluster "${cluster.id}"`, error)
|
||||
printLog(`Failed to migrate Kubeconfig for cluster "${cluster.id}"`, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user