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

@@ -5,7 +5,7 @@
import emitAppEventInjectable from "../../common/app-event-bus/emit-event.injectable";
import getClusterByIdInjectable from "../../common/cluster-store/get-by-id.injectable";
import { kubectlApplyAllChannel } from "../../common/kube-helpers/channels";
import createResourceApplierInjectable from "../resource-applier/create-resource-applier.injectable";
import resourceApplierInjectable from "../resource-applier/create-resource-applier.injectable";
import { getRequestChannelListenerInjectable } from "../utils/channel/channel-listeners/listener-tokens";
const kubectlApplyAllChannelHandlerInjectable = getRequestChannelListenerInjectable({
@@ -13,7 +13,6 @@ const kubectlApplyAllChannelHandlerInjectable = getRequestChannelListenerInjecta
handler: (di) => {
const getClusterById = di.inject(getClusterByIdInjectable);
const emitAppEvent = di.inject(emitAppEventInjectable);
const createResourceApplier = di.inject(createResourceApplierInjectable);
return async ({
clusterId,
@@ -30,7 +29,9 @@ const kubectlApplyAllChannelHandlerInjectable = getRequestChannelListenerInjecta
};
}
return createResourceApplier(cluster).kubectlApplyAll(resources, extraArgs);
const resourceApplier = di.inject(resourceApplierInjectable, cluster);
return resourceApplier.kubectlApplyAll(resources, extraArgs);
};
},
});
@@ -19,10 +19,12 @@ import joinPathsInjectable from "../../common/path/join-paths.injectable";
import getBasenameOfPathInjectable from "../../common/path/get-basename.injectable";
import loggerInjectable from "../../common/logger.injectable";
export type CreateKubectl = (version: string) => Kubectl;
const createKubectlInjectable = getInjectable({
id: "create-kubectl",
instantiate: (di) => {
instantiate: (di): CreateKubectl => {
const dependencies: KubectlDependencies = {
userStore: di.inject(userStoreInjectable),
directoryForKubectlBinaries: di.inject(directoryForKubectlBinariesInjectable),
@@ -39,7 +41,7 @@ const createKubectlInjectable = getInjectable({
getBasenameOfPath: di.inject(getBasenameOfPathInjectable),
};
return (clusterVersion: string) => new Kubectl(dependencies, clusterVersion);
return (version) => new Kubectl(dependencies, version);
},
});
@@ -5,7 +5,7 @@
import emitAppEventInjectable from "../../common/app-event-bus/emit-event.injectable";
import getClusterByIdInjectable from "../../common/cluster-store/get-by-id.injectable";
import { kubectlDeleteAllChannel } from "../../common/kube-helpers/channels";
import createResourceApplierInjectable from "../resource-applier/create-resource-applier.injectable";
import resourceApplierInjectable from "../resource-applier/create-resource-applier.injectable";
import { getRequestChannelListenerInjectable } from "../utils/channel/channel-listeners/listener-tokens";
const kubectlDeleteAllChannelHandlerInjectable = getRequestChannelListenerInjectable({
@@ -13,7 +13,6 @@ const kubectlDeleteAllChannelHandlerInjectable = getRequestChannelListenerInject
handler: (di) => {
const emitAppEvent = di.inject(emitAppEventInjectable);
const getClusterById = di.inject(getClusterByIdInjectable);
const createResourceApplier = di.inject(createResourceApplierInjectable);
return async ({
clusterId,
@@ -31,7 +30,9 @@ const kubectlDeleteAllChannelHandlerInjectable = getRequestChannelListenerInject
};
}
return createResourceApplier(cluster).kubectlDeleteAll(resources, extraArgs);
const resourceApplier = di.inject(resourceApplierInjectable, cluster);
return resourceApplier.kubectlDeleteAll(resources, extraArgs);
};
},
});