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

Shorter kubeconfig-sync file label (#2853)

* shorter kubeconfig-sync file label

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix tests

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-05-25 20:09:04 +03:00 committed by GitHub
parent 73b5d30692
commit 96c3d8d3f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -28,6 +28,12 @@ import mockFs from "mock-fs";
import fs from "fs"; import fs from "fs";
import { ClusterStore } from "../../../common/cluster-store"; import { ClusterStore } from "../../../common/cluster-store";
jest.mock("electron", () => ({
app: {
getPath: () => "/foo",
},
}));
describe("kubeconfig-sync.source tests", () => { describe("kubeconfig-sync.source tests", () => {
beforeEach(() => { beforeEach(() => {
mockFs(); mockFs();

View File

@ -35,6 +35,7 @@ import { catalogEntityFromCluster } from "../cluster-manager";
import { UserStore } from "../../common/user-store"; import { UserStore } from "../../common/user-store";
import { ClusterStore, UpdateClusterModel } from "../../common/cluster-store"; import { ClusterStore, UpdateClusterModel } from "../../common/cluster-store";
import { createHash } from "crypto"; import { createHash } from "crypto";
import { homedir } from "os";
const logPrefix = "[KUBECONFIG-SYNC]:"; const logPrefix = "[KUBECONFIG-SYNC]:";
@ -193,7 +194,9 @@ export function computeDiff(contents: string, source: RootSource, filePath: stri
const entity = catalogEntityFromCluster(cluster); 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]); source.set(contextName, [cluster, entity]);
logger.debug(`${logPrefix} Added new cluster from sync`, { filePath, contextName }); logger.debug(`${logPrefix} Added new cluster from sync`, { filePath, contextName });