Fix editing of kube resource (#5906)

This commit is contained in:
Janne Savolainen authored and GitHub committed 2022-07-27 11:44:11 -04:00
1 parent b94672b5a8
commit e682c7de45
59 files changed
+14123 -298

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
};