1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

cluster-store-3.6.0 migration regression fix

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-07-14 19:51:35 +03:00
parent a305b04292
commit 67377af52e
2 changed files with 7 additions and 6 deletions

View File

@ -74,14 +74,14 @@ export class BaseStore<T = any> extends Singleton {
);
if (ipcMain) {
ipcMain.on(this.syncEvent, (event, model: T) => {
logger.info(`[STORE]: ${this.name} sync update from renderer`, model);
logger.debug(`[STORE]: ${this.name} sync update from renderer`, model);
this.onSync(model);
});
this.syncDisposers.push(() => ipcMain.removeAllListeners(this.syncEvent));
}
if (ipcRenderer) {
ipcRenderer.on(this.syncEvent, (event, model: T) => {
logger.info(`[STORE]: ${this.name} sync update from main`, model);
logger.debug(`[STORE]: ${this.name} sync update from main`, model);
this.onSync(model);
});
this.syncDisposers.push(() => ipcRenderer.removeAllListeners(this.syncEvent));
@ -95,18 +95,17 @@ export class BaseStore<T = any> extends Singleton {
protected onSync(model: T) {
if (!isEqual(this.toJSON(), model)) {
logger.info(`[STORE]: ${this.name} received update from main`, model);
this.fromStore(model);
}
}
protected async onModelChange(model: T) {
// update views and save to config file
if (ipcMain) {
broadcastMessage(this.syncEvent, model);
broadcastMessage(this.syncEvent, model); // send updates to renderer views
// fixme: https://github.com/sindresorhus/conf/issues/114
Object.entries(model).forEach(([key, value]) => {
this.storeConfig.set(key, value);
this.storeConfig.set(key, value); // save update to config file
});
}
// sends "update-request" event to main-process

View File

@ -6,6 +6,7 @@ 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";
export default migration({
version: "3.6.0-beta.1",
@ -22,6 +23,7 @@ export default migration({
try {
// take the embedded kubeconfig and dump it into a file
cluster.kubeConfigPath = writeEmbeddedKubeConfig(cluster.id, cluster.kubeConfig)
cluster.contextName = loadConfig(cluster.kubeConfigPath).getCurrentContext();
delete cluster.kubeConfig;
migratedClusters.push(cluster)
} catch (error) {