diff --git a/src/common/cluster-store.ts b/src/common/cluster-store.ts index b637bddac3..0812358a78 100644 --- a/src/common/cluster-store.ts +++ b/src/common/cluster-store.ts @@ -241,8 +241,8 @@ export class ClusterStore extends BaseStore { cluster = new Cluster(clusterModel); } newClusters.set(clusterModel.id, cluster); - } catch { - // ignore + } catch (error) { + logger.warn(`[CLUSTER-STORE]: Failed to update/create a cluster: ${error}`); } } diff --git a/src/migrations/cluster-store/5.0.0-beta.13.ts b/src/migrations/cluster-store/5.0.0-beta.13.ts index 09628ed234..ace040e2fe 100644 --- a/src/migrations/cluster-store/5.0.0-beta.13.ts +++ b/src/migrations/cluster-store/5.0.0-beta.13.ts @@ -70,12 +70,13 @@ function mergeSet(left: Iterable, right: Iterable): string[] { function mergeClusterModel(prev: ClusterModel, right: Omit): ClusterModel { return { id: prev.id, - kubeConfigPath: prev.id, + kubeConfigPath: prev.kubeConfigPath, contextName: prev.contextName, preferences: mergePreferences(prev.preferences ?? {}, right.preferences ?? {}), metadata: prev.metadata, labels: mergeLabels(prev.labels ?? {}, right.labels ?? {}), accessibleNamespaces: mergeSet(prev.accessibleNamespaces ?? [], right.accessibleNamespaces ?? []), + workspace: prev.workspace || right.workspace, }; } @@ -105,8 +106,10 @@ export default { const newId = generateNewIdFor(cluster); if (clusters.has(newId)) { + migrationLog(`Duplicate entries for ${newId}`, { oldId }); clusters.set(newId, mergeClusterModel(clusters.get(newId), cluster)); } else { + migrationLog(`First entry for ${newId}`, { oldId }); clusters.set(newId, { ...cluster, id: newId, diff --git a/src/migrations/hotbar-store/5.0.0-beta.10.ts b/src/migrations/hotbar-store/5.0.0-beta.10.ts index 41b4aeb081..97efd0ce1d 100644 --- a/src/migrations/hotbar-store/5.0.0-beta.10.ts +++ b/src/migrations/hotbar-store/5.0.0-beta.10.ts @@ -21,13 +21,13 @@ import { app } from "electron"; import fse from "fs-extra"; -import { isNull, uniqBy } from "lodash"; +import { isNull } from "lodash"; import path from "path"; import * as uuid from "uuid"; import type { ClusterStoreModel } from "../../common/cluster-store"; import { defaultHotbarCells, Hotbar, HotbarStore } from "../../common/hotbar-store"; import { catalogEntity } from "../../main/catalog-sources/general"; -import type { MigrationDeclaration } from "../helpers"; +import { MigrationDeclaration, migrationLog } from "../helpers"; import { generateNewIdFor } from "../utils"; interface Pre500WorkspaceStoreModel { @@ -47,9 +47,9 @@ export default { const workspaceStoreData: Pre500WorkspaceStoreModel = fse.readJsonSync(path.join(userDataPath, "lens-workspace-store.json")); const { clusters }: ClusterStoreModel = fse.readJSONSync(path.join(userDataPath, "lens-cluster-store.json")); const workspaceHotbars = new Map(); // mapping from WorkspaceId to HotBar - const uniqueClusters = uniqBy(clusters, "metadata.id"); // Filtering out duplicated clusters for (const { id, name } of workspaceStoreData.workspaces) { + migrationLog(`Creating new hotbar for ${name}`); workspaceHotbars.set(id, { id: uuid.v4(), // don't use the old IDs as they aren't necessarily UUIDs items: [], @@ -69,9 +69,12 @@ export default { }); } - for (const cluster of uniqueClusters) { + for (const cluster of clusters) { + const uid = generateNewIdFor(cluster); const workspaceHotbar = workspaceHotbars.get(cluster.workspace); + migrationLog(`Adding cluster ${uid} to ${workspaceHotbar.name}`); + if (workspaceHotbar?.items.length < defaultHotbarCells) { workspaceHotbar.items.push({ entity: { @@ -83,6 +86,11 @@ export default { } for (const hotbar of workspaceHotbars.values()) { + if (hotbar.items.length === 0) { + migrationLog(`Skipping ${hotbar.name} due to it being empty`); + continue; + } + while (hotbar.items.length < defaultHotbarCells) { hotbar.items.push(null); }