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

Removing dead code

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-11-25 12:26:21 -05:00
parent 78a4177621
commit c1c44471a3
2 changed files with 3 additions and 24 deletions

View File

@ -1,20 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { KubeResource } from "../rbac";
import { apiResourceRecord, apiResources } from "../rbac";
export const isAllowedResource = (allowedResources: string[]) => (kind: string): boolean => {
if ((kind as KubeResource) in apiResourceRecord) {
return allowedResources.includes(kind);
}
const apiResource = apiResources.find(resource => resource.kind === kind);
if (apiResource) {
return allowedResources.includes(apiResource.apiName);
}
return true; // allowed by default for other resources
};

View File

@ -52,7 +52,6 @@ import hostedClusterIdInjectable from "../../cluster-frame-context/hosted-cluste
import activeKubernetesClusterInjectable from "../../cluster-frame-context/active-kubernetes-cluster.injectable";
import { catalogEntityFromCluster } from "../../../main/cluster/manager";
import namespaceStoreInjectable from "../+namespaces/store.injectable";
import { isAllowedResource } from "../../../common/cluster/is-allowed-resource";
import createApplicationWindowInjectable from "../../../main/start-main-application/lens-window/application-window/create-application-window.injectable";
import type { CreateElectronWindow } from "../../../main/start-main-application/lens-window/application-window/create-electron-window.injectable";
import createElectronWindowInjectable from "../../../main/start-main-application/lens-window/application-window/create-electron-window.injectable";
@ -214,7 +213,7 @@ export const getApplicationBuilder = () => {
},
}));
const allowedResourcesState = observable.array<KubeResource>();
const allowedResourcesState = observable.array<string>();
const windowHelpers = new Map<string, { di: DiContainer; getRendered: () => RenderResult }>();
@ -509,8 +508,8 @@ export const getApplicationBuilder = () => {
const clusterStub = {
id: "some-cluster-id",
accessibleNamespaces: [],
isAllowedResource: isAllowedResource(allowedResourcesState),
} as unknown as Cluster;
isAllowedResource: (kind) => allowedResourcesState.includes(kind),
} as Partial<Cluster> as Cluster;
windowDi.override(activeKubernetesClusterInjectable, () =>
computed(() => catalogEntityFromCluster(clusterStub)),