1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix crash due to trying to read hostedCluster too soon

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-12-16 10:49:07 -05:00
parent 3dbe01e830
commit 266e43b557

View File

@ -3,26 +3,19 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import assert from "assert";
import type { ClusterContext } from "./cluster-frame-context";
import hostedClusterInjectable from "./hosted-cluster.injectable";
const clusterFrameContextForClusterScopedResourcesInjectable = getInjectable({
id: "cluster-frame-context-for-cluster-scoped-resources",
instantiate: (di): ClusterContext => {
const cluster = di.inject(hostedClusterInjectable);
assert(cluster, "This can only be injected within a cluster frame");
return {
isGlobalWatchEnabled: () => cluster.isGlobalWatchEnabled,
// This is always the case for cluster scoped resources
isLoadingAll: () => true,
allNamespaces: [],
contextNamespaces: [], // This value is used as a sentinal
hasSelectedAll: true,
};
},
instantiate: (): ClusterContext => ({
// This doesn't matter as it is an optimization for namespaced resources only
isGlobalWatchEnabled: () => true,
// This is always the case for cluster scoped resources
isLoadingAll: () => true,
allNamespaces: [],
contextNamespaces: [],
hasSelectedAll: true,
}),
});
export default clusterFrameContextForClusterScopedResourcesInjectable;