mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import { getInjectable } from "@ogre-tools/injectable";
|
|
import assert from "assert";
|
|
import allNamespacesInjectable from "./all-namespaces.injectable";
|
|
import hostedClusterInjectable from "./hosted-cluster.injectable";
|
|
|
|
export type IsNamespaceListSufficientToLoadFromAllNamespaces = (namespace: string[]) => boolean;
|
|
|
|
const isNamespaceListSufficientToLoadFromAllNamespacesInjectable = getInjectable({
|
|
id: "is-namespace-list-sufficient-to-load-from-all-namespaces",
|
|
instantiate: (di): IsNamespaceListSufficientToLoadFromAllNamespaces => {
|
|
const cluster = di.inject(hostedClusterInjectable);
|
|
|
|
assert(cluster, "This can only be injected within a cluster frame");
|
|
|
|
const allNamespaces = di.inject(allNamespacesInjectable);
|
|
|
|
return (namespaces) => (
|
|
allNamespaces.get().length > 1
|
|
&& cluster.accessibleNamespaces.length === 0
|
|
&& allNamespaces.get().every(ns => namespaces.includes(ns))
|
|
);
|
|
},
|
|
});
|
|
|
|
export default isNamespaceListSufficientToLoadFromAllNamespacesInjectable;
|