-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix request namespace list permissions check if a list rule is not the first match (#7282) Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * Fix cluster metadata detectors (#7255) Signed-off-by: Juho Heikka <juho.heikka@gmail.com> * Fix extension API not having all the correct types (#7263) Signed-off-by: Sebastian Malton <sebastian@malton.name> * Update release guide and fix release script (#7276) Signed-off-by: Sebastian Malton <sebastian@malton.name> * Release 6.4.2 Signed-off-by: Juho Heikka <juho.heikka@gmail.com> --------- Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> Signed-off-by: Juho Heikka <juho.heikka@gmail.com> Signed-off-by: Sebastian Malton <sebastian@malton.name> Co-authored-by: Sebastian Malton <sebastian@malton.name>
- Loading branch information
Showing
9 changed files
with
142 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
packages/core/src/main/cluster-detectors/detect-cluster-metadata.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import type { AppPaths } from "../../common/app-paths/app-path-injection-token"; | ||
import appPathsStateInjectable from "../../common/app-paths/app-paths-state.injectable"; | ||
import directoryForKubeConfigsInjectable from "../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable"; | ||
import directoryForUserDataInjectable from "../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable"; | ||
import { ClusterMetadataKey } from "../../common/cluster-types"; | ||
import type { Cluster } from "../../common/cluster/cluster"; | ||
import { createClusterInjectionToken } from "../../common/cluster/create-cluster-injection-token"; | ||
import { getDiForUnitTesting } from "../getDiForUnitTesting"; | ||
import clusterDistributionDetectorInjectable from "./cluster-distribution-detector.injectable"; | ||
import clusterIdDetectorFactoryInjectable from "./cluster-id-detector.injectable"; | ||
import clusterLastSeenDetectorInjectable from "./cluster-last-seen-detector.injectable"; | ||
import clusterNodeCountDetectorInjectable from "./cluster-nodes-count-detector.injectable"; | ||
import type { DetectClusterMetadata } from "./detect-cluster-metadata.injectable"; | ||
import detectClusterMetadataInjectable from "./detect-cluster-metadata.injectable"; | ||
import requestClusterVersionInjectable from "./request-cluster-version.injectable"; | ||
|
||
describe("detect-cluster-metadata", () => { | ||
let detectClusterMetadata: DetectClusterMetadata; | ||
|
||
let cluster: Cluster; | ||
|
||
beforeEach(async () => { | ||
const di = getDiForUnitTesting({ doGeneralOverrides: true }); | ||
|
||
const lastSeenDetectMock = jest.fn().mockReturnValue(Promise.resolve({ value: "some-time-stamp", accuracy: 100 })); | ||
const nodeCountDetectMock = jest.fn().mockReturnValue(Promise.resolve({ value: 42, accuracy: 100 })); | ||
const clusterIdDetectMock = jest.fn().mockReturnValue(Promise.resolve({ value: "some-cluster-id", accuracy: 100 })); | ||
const distributionDetectMock = jest.fn().mockReturnValue(Promise.resolve({ value: "some-distribution", accuracy: 100 })); | ||
|
||
di.override(clusterLastSeenDetectorInjectable, () => { | ||
return { | ||
key: ClusterMetadataKey.LAST_SEEN, | ||
detect: lastSeenDetectMock, | ||
}; | ||
}); | ||
|
||
di.override(requestClusterVersionInjectable, () => () => Promise.resolve("some-cluster-version")); | ||
|
||
di.override(clusterNodeCountDetectorInjectable, () => ({ | ||
key: ClusterMetadataKey.NODES_COUNT, | ||
detect: nodeCountDetectMock, | ||
})); | ||
|
||
di.override(clusterIdDetectorFactoryInjectable, () => ({ | ||
key: ClusterMetadataKey.CLUSTER_ID, | ||
detect: clusterIdDetectMock, | ||
})); | ||
|
||
di.override(clusterDistributionDetectorInjectable, () => ({ | ||
key: ClusterMetadataKey.DISTRIBUTION, | ||
detect: distributionDetectMock, | ||
})); | ||
|
||
di.override(directoryForUserDataInjectable, () => "/some-user-store-path"); | ||
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs"); | ||
di.override(appPathsStateInjectable, () => ({ | ||
get: () => ({} as AppPaths), | ||
set: () => {}, | ||
})); | ||
|
||
detectClusterMetadata = di.inject(detectClusterMetadataInjectable); | ||
|
||
const createCluster = di.inject(createClusterInjectionToken); | ||
|
||
cluster = createCluster({ | ||
id: "some-id", | ||
contextName: "some-context", | ||
kubeConfigPath: "minikube-config.yml", | ||
}, { | ||
clusterServerUrl: "foo", | ||
}); | ||
}); | ||
|
||
it("given some cluster, last seen time stamp is added to the metadata", async () => { | ||
const metadata = await detectClusterMetadata(cluster); | ||
|
||
expect(metadata.lastSeen).toEqual("some-time-stamp"); | ||
}); | ||
|
||
it("given some cluster, cluster version is added to the metadata", async () => { | ||
const metadata = await detectClusterMetadata(cluster); | ||
|
||
expect(metadata.version).toEqual("some-cluster-version"); | ||
}); | ||
|
||
it("given some cluster, id is added to the metadata", async () => { | ||
const metadata = await detectClusterMetadata(cluster); | ||
|
||
expect(metadata.id).toEqual("some-cluster-id"); | ||
}); | ||
|
||
it("given some cluster, node count is added to the metadata", async () => { | ||
const metadata = await detectClusterMetadata(cluster); | ||
|
||
expect(metadata.nodes).toEqual(42); | ||
}); | ||
|
||
it("given some cluster, distribution is added to the metadata", async () => { | ||
const metadata = await detectClusterMetadata(cluster); | ||
|
||
expect(metadata.distribution).toEqual("some-distribution"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters