mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Cleanup 'Cluster' to remove environment specific details (#6951)
- requestNamespaceListPermissions is infallable so no need to have the extra try/catch - Refactor isMetricHidden method away from Cluster - Refactor shouldShowResource out of Cluster - Refactor isInLocalKubeconfig out of Cluster - Remove depecrated and unused workspace from Cluster - Refactor out kubectl as a dependency of Cluster - Remove from cluster getter used only once - Split out ClusterConnection from Cluster - Also split out KubeAuthProxyServer from ContextHandler - Rename ContextHandler to PrometheusHandler - Cleanup onNetworkOffline/Online impls within ClusterManager - Remove annotations from ClusterConnection - Remove mobx annotations from Cluster - Rename loadConfigFromFileInjectable - Remove all uses of dead createClusterInjectionToken - Fix type errors related to broadcastConnectionUpdate Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
e6d6d1d8f7
commit
ad9bafe2a5
133 files changed
+2544
-1961
No files matched your search
@@ -7,11 +7,10 @@ import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import { KubernetesCluster, WebLink } from "../../common/catalog-entities";
|
||||
import getClusterByIdInjectable from "../../common/cluster-store/get-by-id.injectable";
|
||||
import type { Cluster } from "../../common/cluster/cluster";
|
||||
import { Cluster } from "../../common/cluster/cluster";
|
||||
import navigateToCatalogInjectable from "../../common/front-end-routing/routes/catalog/navigate-to-catalog.injectable";
|
||||
import { advanceFakeTime, testUsingFakeTime } from "../../common/test-utils/use-fake-time";
|
||||
import catalogEntityRegistryInjectable from "../../renderer/api/catalog/entity/registry.injectable";
|
||||
import createClusterInjectable from "../../renderer/cluster/create-cluster.injectable";
|
||||
import showEntityDetailsInjectable from "../../renderer/components/+catalog/entity-details/show.injectable";
|
||||
import { type ApplicationBuilder, getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
|
||||
@@ -41,8 +40,6 @@ describe("opening catalog entity details panel", () => {
|
||||
testUsingFakeTime();
|
||||
|
||||
builder.afterWindowStart((windowDi) => {
|
||||
const createCluster = windowDi.inject(createClusterInjectable);
|
||||
|
||||
clusterEntity = new KubernetesCluster({
|
||||
metadata: {
|
||||
labels: {},
|
||||
@@ -85,7 +82,7 @@ describe("opening catalog entity details panel", () => {
|
||||
phase: "available",
|
||||
},
|
||||
});
|
||||
cluster = createCluster({
|
||||
cluster = new Cluster({
|
||||
contextName: clusterEntity.spec.kubeconfigContext,
|
||||
id: clusterEntity.getId(),
|
||||
kubeConfigPath: clusterEntity.spec.kubeconfigPath,
|
||||
|
||||
@@ -5,16 +5,12 @@
|
||||
import "@testing-library/jest-dom/extend-expect";
|
||||
import { KubeConfig } from "@kubernetes/client-node";
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import type { CreateCluster } from "../../../common/cluster/create-cluster-injection-token";
|
||||
import { createClusterInjectionToken } from "../../../common/cluster/create-cluster-injection-token";
|
||||
import createContextHandlerInjectable from "../../../main/context-handler/create-context-handler.injectable";
|
||||
import createKubeconfigManagerInjectable from "../../../main/kubeconfig-manager/create-kubeconfig-manager.injectable";
|
||||
import normalizedPlatformInjectable from "../../../common/vars/normalized-platform.injectable";
|
||||
import kubectlBinaryNameInjectable from "../../../main/kubectl/binary-name.injectable";
|
||||
import kubectlDownloadingNormalizedArchInjectable from "../../../main/kubectl/normalized-arch.injectable";
|
||||
import openDeleteClusterDialogInjectable, { type OpenDeleteClusterDialog } from "../../../renderer/components/delete-cluster-dialog/open.injectable";
|
||||
import { type ApplicationBuilder, getApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import { Cluster } from "../../../common/cluster/cluster";
|
||||
import navigateToCatalogInjectable from "../../../common/front-end-routing/routes/catalog/navigate-to-catalog.injectable";
|
||||
import directoryForKubeConfigsInjectable from "../../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable";
|
||||
import joinPathsInjectable from "../../../common/path/join-paths.injectable";
|
||||
@@ -73,7 +69,6 @@ users:
|
||||
describe("Deleting a cluster", () => {
|
||||
let builder: ApplicationBuilder;
|
||||
let openDeleteClusterDialog: OpenDeleteClusterDialog;
|
||||
let createCluster: CreateCluster;
|
||||
let rendered: RenderResult;
|
||||
let config: KubeConfig;
|
||||
|
||||
@@ -82,8 +77,6 @@ describe("Deleting a cluster", () => {
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(createContextHandlerInjectable, () => () => undefined as never);
|
||||
mainDi.override(createKubeconfigManagerInjectable, () => () => undefined as never);
|
||||
mainDi.override(kubectlBinaryNameInjectable, () => "kubectl");
|
||||
mainDi.override(kubectlDownloadingNormalizedArchInjectable, () => "amd64");
|
||||
mainDi.override(normalizedPlatformInjectable, () => "darwin");
|
||||
@@ -94,8 +87,6 @@ describe("Deleting a cluster", () => {
|
||||
});
|
||||
|
||||
builder.afterWindowStart(windowDi => {
|
||||
createCluster = windowDi.inject(createClusterInjectionToken);
|
||||
|
||||
const navigateToCatalog = windowDi.inject(navigateToCatalogInjectable);
|
||||
|
||||
navigateToCatalog();
|
||||
@@ -111,7 +102,7 @@ describe("Deleting a cluster", () => {
|
||||
beforeEach(() => {
|
||||
config.loadFromString(multiClusterConfig);
|
||||
|
||||
currentCluster = createCluster({
|
||||
currentCluster = new Cluster({
|
||||
id: "some-current-context-cluster",
|
||||
contextName: "some-current-context",
|
||||
preferences: {
|
||||
@@ -121,7 +112,7 @@ describe("Deleting a cluster", () => {
|
||||
}, {
|
||||
clusterServerUrl: currentClusterServerUrl,
|
||||
});
|
||||
nonCurrentCluster = createCluster({
|
||||
nonCurrentCluster = new Cluster({
|
||||
id: "some-non-current-context-cluster",
|
||||
contextName: "some-non-current-context",
|
||||
preferences: {
|
||||
@@ -199,7 +190,7 @@ describe("Deleting a cluster", () => {
|
||||
const directoryForKubeConfigs = builder.applicationWindow.only.di.inject(directoryForKubeConfigsInjectable);
|
||||
const joinPaths = builder.applicationWindow.only.di.inject(joinPathsInjectable);
|
||||
|
||||
currentCluster = createCluster({
|
||||
currentCluster = new Cluster({
|
||||
id: "some-cluster",
|
||||
contextName: "some-context",
|
||||
preferences: {
|
||||
@@ -235,7 +226,7 @@ describe("Deleting a cluster", () => {
|
||||
beforeEach(() => {
|
||||
config.loadFromString(singleClusterConfig);
|
||||
|
||||
currentCluster = createCluster({
|
||||
currentCluster = new Cluster({
|
||||
id: "some-cluster",
|
||||
contextName: "some-context",
|
||||
preferences: {
|
||||
|
||||
+4
-1
@@ -9,6 +9,7 @@ import directoryForLensLocalStorageInjectable from "../../../../common/directory
|
||||
import removePathInjectable from "../../../../common/fs/remove.injectable";
|
||||
import joinPathsInjectable from "../../../../common/path/join-paths.injectable";
|
||||
import { noop } from "../../../../common/utils";
|
||||
import clusterConnectionInjectable from "../../../../main/cluster/cluster-connection.injectable";
|
||||
import { getRequestChannelListenerInjectable } from "../../../../main/utils/channel/channel-listeners/listener-tokens";
|
||||
import { deleteClusterChannel } from "../common/delete-channel";
|
||||
|
||||
@@ -31,7 +32,9 @@ const deleteClusterChannelListenerInjectable = getRequestChannelListenerInjectab
|
||||
return;
|
||||
}
|
||||
|
||||
cluster.disconnect();
|
||||
const clusterConnection = di.inject(clusterConnectionInjectable, cluster);
|
||||
|
||||
clusterConnection.disconnect();
|
||||
clusterFrames.delete(cluster.id);
|
||||
|
||||
// Remove from the cluster store as well, this should clear any old settings
|
||||
|
||||
@@ -64,9 +64,11 @@ describe("cluster/namespaces - edit namespace from new tab", () => {
|
||||
windowDi.override(callForPatchResourceInjectable, () => callForPatchResourceMock);
|
||||
});
|
||||
|
||||
builder.allowKubeResource({
|
||||
apiName: "namespaces",
|
||||
group: "",
|
||||
builder.afterWindowStart(() => {
|
||||
builder.allowKubeResource({
|
||||
apiName: "namespaces",
|
||||
group: "",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+5
-3
@@ -35,9 +35,11 @@ describe("cluster/namespaces - edit namespaces from previously opened tab", () =
|
||||
windowDi.override(callForResourceInjectable, () => callForNamespaceMock);
|
||||
});
|
||||
|
||||
builder.allowKubeResource({
|
||||
apiName: "namespaces",
|
||||
group: "",
|
||||
builder.afterWindowStart(() => {
|
||||
builder.allowKubeResource({
|
||||
apiName: "namespaces",
|
||||
group: "",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -9,20 +9,24 @@ import { type ApplicationBuilder, getApplicationBuilder } from "../../renderer/c
|
||||
|
||||
describe("workload overview", () => {
|
||||
let rendered: RenderResult;
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder = getApplicationBuilder().setEnvironmentToClusterFrame();
|
||||
applicationBuilder.allowKubeResource({
|
||||
apiName: "pods",
|
||||
group: "",
|
||||
builder = getApplicationBuilder().setEnvironmentToClusterFrame();
|
||||
|
||||
builder.afterWindowStart(() => {
|
||||
builder.allowKubeResource({
|
||||
apiName: "pods",
|
||||
group: "",
|
||||
});
|
||||
});
|
||||
rendered = await applicationBuilder.render();
|
||||
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
describe("when navigating to workload overview", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.navigateWith(navigateToWorkloadsOverviewInjectable);
|
||||
builder.navigateWith(navigateToWorkloadsOverviewInjectable);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
|
||||
+2
-5
@@ -7,11 +7,10 @@ import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import { KubernetesCluster, WebLink } from "../../common/catalog-entities";
|
||||
import getClusterByIdInjectable from "../../common/cluster-store/get-by-id.injectable";
|
||||
import type { Cluster } from "../../common/cluster/cluster";
|
||||
import { Cluster } from "../../common/cluster/cluster";
|
||||
import navigateToEntitySettingsInjectable from "../../common/front-end-routing/routes/entity-settings/navigate-to-entity-settings.injectable";
|
||||
import catalogEntityRegistryInjectable from "../../renderer/api/catalog/entity/registry.injectable";
|
||||
import { type ApplicationBuilder, getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import createClusterInjectable from "../../renderer/cluster/create-cluster.injectable";
|
||||
|
||||
describe("Showing correct entity settings", () => {
|
||||
let builder: ApplicationBuilder;
|
||||
@@ -37,8 +36,6 @@ describe("Showing correct entity settings", () => {
|
||||
});
|
||||
|
||||
builder.afterWindowStart((windowDi) => {
|
||||
const createCluster = windowDi.inject(createClusterInjectable);
|
||||
|
||||
clusterEntity = new KubernetesCluster({
|
||||
metadata: {
|
||||
labels: {},
|
||||
@@ -81,7 +78,7 @@ describe("Showing correct entity settings", () => {
|
||||
phase: "available",
|
||||
},
|
||||
});
|
||||
cluster = createCluster({
|
||||
cluster = new Cluster({
|
||||
contextName: clusterEntity.spec.kubeconfigContext,
|
||||
id: clusterEntity.getId(),
|
||||
kubeConfigPath: clusterEntity.spec.kubeconfigPath,
|
||||
|
||||
Reference in new issue
Block a user