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

@@ -14,8 +14,7 @@ import { DefaultProps } from "../../mui-base-theme";
import { ClusterFrame } from "./cluster-frame";
import historyInjectable from "../../navigation/history.injectable";
import { computed } from "mobx";
import type { Cluster } from "../../../common/cluster/cluster";
import createClusterInjectable from "../../cluster/create-cluster.injectable";
import { Cluster } from "../../../common/cluster/cluster";
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
import directoryForUserDataInjectable from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable";
@@ -49,9 +48,7 @@ describe("<ClusterFrame />", () => {
testUsingFakeTime("2000-01-01 12:00:00am");
const createCluster = di.inject(createClusterInjectable);
cluster = createCluster(
cluster = new Cluster(
{
contextName: "my-cluster",
id: "123456",
@@ -68,8 +65,7 @@ describe("<ClusterFrame />", () => {
describe("given cluster with list nodes and namespaces permissions", () => {
beforeEach(() => {
// TODO: replace with not using private info
(cluster as unknown as { readonly allowedResources: Cluster["allowedResources"] }).allowedResources.replace(["nodes", "namespaces"]);
cluster.resourcesToShow.replace(["nodes", "namespaces"]);
});
it("renders", () => {
@@ -110,7 +106,7 @@ describe("<ClusterFrame />", () => {
describe("given cluster without list nodes, but with namespaces permissions", () => {
beforeEach(() => {
(cluster as unknown as { readonly allowedResources: Cluster["allowedResources"] }).allowedResources.replace(["namespaces"]);
cluster.resourcesToShow.replace(["namespaces"]);
});
it("renders", () => {
@@ -40,7 +40,7 @@ export const initClusterFrame = ({
);
await requestSetClusterFrameId(hostedCluster.id);
await hostedCluster.whenReady; // cluster.activate() is done at this point
await when(() => hostedCluster.ready.get()); // cluster.activate() is done at this point
catalogEntityRegistry.activeEntity = hostedCluster.id;