Rework editing resource to fix multiple bugs and introduce behaviours for it

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen committed 2022-07-27 09:22:42 +03:00
1 parent 27684ade67
commit 5cf704ae0b
17 files changed
+13791 -197

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
/**
* 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
};