mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
all Roles tab to be viewed if cluster has access to clusterrole
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
ca152e1cc5
commit
73492ee287
@ -5,7 +5,7 @@ export type KubeResource =
|
||||
"secrets" | "configmaps" | "ingresses" | "networkpolicies" | "persistentvolumeclaims" | "persistentvolumes" | "storageclasses" |
|
||||
"pods" | "daemonsets" | "deployments" | "statefulsets" | "replicasets" | "jobs" | "cronjobs" |
|
||||
"endpoints" | "customresourcedefinitions" | "horizontalpodautoscalers" | "podsecuritypolicies" | "poddisruptionbudgets" |
|
||||
"role" | "rolebinding" | "clusterrolebinding" | "serviceaccount";
|
||||
"role" | "clusterrole" | "rolebinding" | "clusterrolebinding" | "serviceaccount";
|
||||
|
||||
export interface KubeApiResource extends KubeApiResourceData {
|
||||
apiName: KubeResource; // valid api resource name (e.g. "namespaces")
|
||||
@ -17,6 +17,7 @@ export interface KubeApiResourceData {
|
||||
}
|
||||
|
||||
export const apiResources: Record<KubeResource, KubeApiResourceData> = {
|
||||
"clusterrole": { kind: "ClusterRole", group: "rbac.authorization.k8s.io" },
|
||||
"clusterrolebinding": { kind: "ClusterRoleBinding", group: "rbac.authorization.k8s.io" },
|
||||
"configmaps": { kind: "ConfigMap" },
|
||||
"cronjobs": { kind: "CronJob", group: "batch" },
|
||||
|
||||
@ -36,7 +36,7 @@ import { Cluster } from "../cluster";
|
||||
import { ContextHandler } from "../context-handler";
|
||||
import { getFreePort } from "../port";
|
||||
import { V1ResourceAttributes } from "@kubernetes/client-node";
|
||||
import { apiResources } from "../../common/rbac";
|
||||
import { apiResourceList } from "../../common/rbac";
|
||||
import request from "request-promise-native";
|
||||
import { Kubectl } from "../kubectl";
|
||||
|
||||
@ -173,7 +173,7 @@ describe("create clusters", () => {
|
||||
expect(mockedRequest).toBeCalled();
|
||||
expect(c.accessible).toBe(true);
|
||||
expect(c.allowedNamespaces.length).toBe(1);
|
||||
expect(c.allowedResources.length).toBe(apiResources.length);
|
||||
expect(c.allowedResources.length).toBe(apiResourceList.length);
|
||||
c.disconnect();
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
@ -35,7 +35,8 @@ export class UserManagement extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
if (isAllowedResource("role")) {
|
||||
if (isAllowedResource("role") || isAllowedResource("clusterrole")) {
|
||||
// TODO: seperate out these two pages
|
||||
tabRoutes.push({
|
||||
title: "Roles",
|
||||
component: Roles,
|
||||
|
||||
@ -29,5 +29,6 @@ export const ResourceNames: Record<KubeResource, string> = {
|
||||
"role": "Roles",
|
||||
"rolebinding": "Role Bindings",
|
||||
"clusterrolebinding": "Cluster Role Bindings",
|
||||
"clusterrole": "Cluster Roles",
|
||||
"serviceaccount": "Service Accounts"
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user