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:
Sebastian Malton authored and GitHub committed 2023-03-10 09:37:39 +02:00
1 parent e6d6d1d8f7
commit ad9bafe2a5
133 files changed
+2544 -1961

No files matched your search

@@ -22,7 +22,7 @@ import navigateToPreferencesInjectable from "../../../features/preferences/commo
import type { NavigateToHelmCharts } from "../../../common/front-end-routing/routes/cluster/helm/charts/navigate-to-helm-charts.injectable";
import navigateToHelmChartsInjectable from "../../../common/front-end-routing/routes/cluster/helm/charts/navigate-to-helm-charts.injectable";
import hostedClusterInjectable from "../../cluster-frame-context/hosted-cluster.injectable";
import type { Cluster } from "../../../common/cluster/cluster";
import { Cluster } from "../../../common/cluster/cluster";
import type { NamespaceStore } from "../+namespaces/store";
import historyInjectable from "../../navigation/history.injectable";
import type { MinimalTrayMenuItem } from "../../../main/tray/electron-tray/electron-tray.injectable";
@@ -228,8 +228,6 @@ export const getApplicationBuilder = () => {
},
}));
const allowedResourcesState = observable.set<string>();
const windowHelpers = new Map<string, { di: DiContainer; getRendered: () => RenderResult }>();
const createElectronWindowFake: CreateElectronWindow = (configuration) => {
@@ -526,19 +524,20 @@ export const getApplicationBuilder = () => {
environment = environments.clusterFrame;
builder.beforeWindowStart((windowDi) => {
const clusterStub = {
const cluster = new Cluster({
id: "some-cluster-id",
accessibleNamespaces: observable.array(),
allowedNamespaces: observable.array(),
shouldShowResource: (kind) => allowedResourcesState.has(formatKubeApiResource(kind)),
} as Partial<Cluster> as Cluster;
contextName: "some-context-name",
kubeConfigPath: "/some-path-to-kube-config",
}, {
clusterServerUrl: "https://localhost:12345",
});
windowDi.override(activeKubernetesClusterInjectable, () =>
computed(() => catalogEntityFromCluster(clusterStub)),
computed(() => catalogEntityFromCluster(cluster)),
);
windowDi.override(hostedClusterIdInjectable, () => clusterStub.id);
windowDi.override(hostedClusterInjectable, () => clusterStub);
windowDi.override(hostedClusterIdInjectable, () => cluster.id);
windowDi.override(hostedClusterInjectable, () => cluster);
// TODO: Figure out a way to remove this stub.
windowDi.override(namespaceStoreInjectable, () => ({
@@ -645,8 +644,11 @@ export const getApplicationBuilder = () => {
allowKubeResource: (resource) => {
environment.onAllowKubeResource();
const windowDi = builder.applicationWindow.only.di;
const cluster = windowDi.inject(hostedClusterInjectable);
runInAction(() => {
allowedResourcesState.add(formatKubeApiResource(resource));
cluster?.resourcesToShow.add(formatKubeApiResource(resource));
});
return builder;