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:
parent
73b5d30692
commit
96c3d8d3f5
@ -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();
|
||||||
|
|||||||
@ -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 });
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user