diff --git a/src/main/catalog-sources/__test__/kubeconfig-sync.test.ts b/src/main/catalog-sources/__test__/kubeconfig-sync.test.ts index 6f89e12c46..7fcd3c1db6 100644 --- a/src/main/catalog-sources/__test__/kubeconfig-sync.test.ts +++ b/src/main/catalog-sources/__test__/kubeconfig-sync.test.ts @@ -28,6 +28,12 @@ import mockFs from "mock-fs"; import fs from "fs"; import { ClusterStore } from "../../../common/cluster-store"; +jest.mock("electron", () => ({ + app: { + getPath: () => "/foo", + }, +})); + describe("kubeconfig-sync.source tests", () => { beforeEach(() => { mockFs(); diff --git a/src/main/catalog-sources/kubeconfig-sync.ts b/src/main/catalog-sources/kubeconfig-sync.ts index 0f481741d6..c4650644da 100644 --- a/src/main/catalog-sources/kubeconfig-sync.ts +++ b/src/main/catalog-sources/kubeconfig-sync.ts @@ -35,6 +35,7 @@ import { catalogEntityFromCluster } from "../cluster-manager"; import { UserStore } from "../../common/user-store"; import { ClusterStore, UpdateClusterModel } from "../../common/cluster-store"; import { createHash } from "crypto"; +import { homedir } from "os"; const logPrefix = "[KUBECONFIG-SYNC]:"; @@ -193,7 +194,9 @@ export function computeDiff(contents: string, source: RootSource, filePath: stri const entity = catalogEntityFromCluster(cluster); - entity.metadata.labels.file = filePath; + if (!filePath.startsWith(ClusterStore.storedKubeConfigFolder)) { + entity.metadata.labels.file = filePath.replace(homedir(), "~"); + } source.set(contextName, [cluster, entity]); logger.debug(`${logPrefix} Added new cluster from sync`, { filePath, contextName });