mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix shouldShowResource when not a cluster admin (#6900)
* Fix shouldShowResource when not a cluster admin Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix only tests that rely on bad formatting of resources Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
841c6b5720
commit
0ec8cbd7ed
23 files changed
+45
-41
No files matched your search
+1
-1
@@ -13,7 +13,7 @@ const configMapsRouteInjectable = getInjectable({
|
||||
clusterFrame: true,
|
||||
isEnabled: di.inject(shouldShowResourceInjectionToken, {
|
||||
apiName: "configmaps",
|
||||
group: "v1",
|
||||
group: "",
|
||||
}),
|
||||
}),
|
||||
injectionToken: frontEndRouteInjectionToken,
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ const limitRangesRouteInjectable = getInjectable({
|
||||
clusterFrame: true,
|
||||
isEnabled: di.inject(shouldShowResourceInjectionToken, {
|
||||
apiName: "limitranges",
|
||||
group: "v1",
|
||||
group: "",
|
||||
}),
|
||||
}),
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ const resourceQuotasRouteInjectable = getInjectable({
|
||||
clusterFrame: true,
|
||||
isEnabled: di.inject(shouldShowResourceInjectionToken, {
|
||||
apiName: "resourcequotas",
|
||||
group: "v1",
|
||||
group: "",
|
||||
}),
|
||||
}),
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ const secretsRouteInjectable = getInjectable({
|
||||
clusterFrame: true,
|
||||
isEnabled: di.inject(shouldShowResourceInjectionToken, {
|
||||
apiName: "secrets",
|
||||
group: "v1",
|
||||
group: "",
|
||||
}),
|
||||
}),
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ const eventsRouteInjectable = getInjectable({
|
||||
clusterFrame: true,
|
||||
isEnabled: di.inject(shouldShowResourceInjectionToken, {
|
||||
apiName: "events",
|
||||
group: "v1",
|
||||
group: "",
|
||||
}),
|
||||
}),
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ const namespacesRouteInjectable = getInjectable({
|
||||
clusterFrame: true,
|
||||
isEnabled: di.inject(shouldShowResourceInjectionToken, {
|
||||
apiName: "namespaces",
|
||||
group: "v1",
|
||||
group: "",
|
||||
}),
|
||||
}),
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ const endpointsRouteInjectable = getInjectable({
|
||||
clusterFrame: true,
|
||||
isEnabled: di.inject(shouldShowResourceInjectionToken, {
|
||||
apiName: "endpoints",
|
||||
group: "v1",
|
||||
group: "",
|
||||
}),
|
||||
}),
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ const servicesRouteInjectable = getInjectable({
|
||||
clusterFrame: true,
|
||||
isEnabled: di.inject(shouldShowResourceInjectionToken, {
|
||||
apiName: "services",
|
||||
group: "v1",
|
||||
group: "",
|
||||
}),
|
||||
}),
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ const nodesRouteInjectable = getInjectable({
|
||||
clusterFrame: true,
|
||||
isEnabled: di.inject(shouldShowResourceInjectionToken, {
|
||||
apiName: "nodes",
|
||||
group: "v1",
|
||||
group: "",
|
||||
}),
|
||||
}),
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ const clusterOverviewRouteInjectable = getInjectable({
|
||||
clusterFrame: true,
|
||||
isEnabled: di.inject(shouldShowResourceInjectionToken, {
|
||||
apiName: "nodes",
|
||||
group: "v1",
|
||||
group: "",
|
||||
}),
|
||||
}),
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ const persistentVolumeClaimsRouteInjectable = getInjectable({
|
||||
clusterFrame: true,
|
||||
isEnabled: di.inject(shouldShowResourceInjectionToken, {
|
||||
apiName: "persistentvolumeclaims",
|
||||
group: "v1",
|
||||
group: "",
|
||||
}),
|
||||
}),
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ const persistentVolumesRouteInjectable = getInjectable({
|
||||
clusterFrame: true,
|
||||
isEnabled: di.inject(shouldShowResourceInjectionToken, {
|
||||
apiName: "persistentvolumes",
|
||||
group: "v1",
|
||||
group: "",
|
||||
}),
|
||||
}),
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ const serviceAccountsRouteInjectable = getInjectable({
|
||||
clusterFrame: true,
|
||||
isEnabled: di.inject(shouldShowResourceInjectionToken, {
|
||||
apiName: "serviceaccounts",
|
||||
group: "v1",
|
||||
group: "",
|
||||
}),
|
||||
}),
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ const podsRouteInjectable = getInjectable({
|
||||
clusterFrame: true,
|
||||
isEnabled: di.inject(shouldShowResourceInjectionToken, {
|
||||
apiName: "pods",
|
||||
group: "v1",
|
||||
group: "",
|
||||
}),
|
||||
}),
|
||||
|
||||
|
||||
+21
-17
@@ -13,17 +13,21 @@ export type KubeResource =
|
||||
|
||||
export interface KubeApiResource {
|
||||
kind: string;
|
||||
group: string;
|
||||
group: string; // api-group, if empty then "core"
|
||||
apiName: string;
|
||||
namespaced: boolean;
|
||||
}
|
||||
|
||||
export interface KubeApiResourceDescriptor {
|
||||
apiName: string;
|
||||
group: string;
|
||||
group: string; // api-group, if empty then "core"
|
||||
}
|
||||
|
||||
export const formatKubeApiResource = (res: KubeApiResourceDescriptor) => `${res.group}/${res.apiName}`;
|
||||
export const formatKubeApiResource = (desc: KubeApiResourceDescriptor) => (
|
||||
desc.group
|
||||
? `${desc.group}/${desc.apiName}`
|
||||
: desc.apiName
|
||||
);
|
||||
|
||||
export interface KubeApiResourceData {
|
||||
kind: string; // resource type (e.g. "Namespace")
|
||||
@@ -44,7 +48,7 @@ export const apiResourceRecord: Record<KubeResource, KubeApiResourceData> = {
|
||||
},
|
||||
configmaps: {
|
||||
kind: "ConfigMap",
|
||||
group: "v1",
|
||||
group: "",
|
||||
namespaced: true,
|
||||
},
|
||||
cronjobs: {
|
||||
@@ -69,12 +73,12 @@ export const apiResourceRecord: Record<KubeResource, KubeApiResourceData> = {
|
||||
},
|
||||
endpoints: {
|
||||
kind: "Endpoint",
|
||||
group: "v1",
|
||||
group: "",
|
||||
namespaced: true,
|
||||
},
|
||||
events: {
|
||||
kind: "Event",
|
||||
group: "v1",
|
||||
group: "",
|
||||
namespaced: true,
|
||||
},
|
||||
horizontalpodautoscalers: {
|
||||
@@ -99,17 +103,17 @@ export const apiResourceRecord: Record<KubeResource, KubeApiResourceData> = {
|
||||
},
|
||||
namespaces: {
|
||||
kind: "Namespace",
|
||||
group: "v1",
|
||||
group: "",
|
||||
namespaced: false,
|
||||
},
|
||||
limitranges: {
|
||||
kind: "LimitRange",
|
||||
group: "v1",
|
||||
group: "",
|
||||
namespaced: true,
|
||||
},
|
||||
leases: {
|
||||
kind: "Lease",
|
||||
group: "v1",
|
||||
group: "",
|
||||
namespaced: true,
|
||||
},
|
||||
networkpolicies: {
|
||||
@@ -119,22 +123,22 @@ export const apiResourceRecord: Record<KubeResource, KubeApiResourceData> = {
|
||||
},
|
||||
nodes: {
|
||||
kind: "Node",
|
||||
group: "v1",
|
||||
group: "",
|
||||
namespaced: false,
|
||||
},
|
||||
persistentvolumes: {
|
||||
kind: "PersistentVolume",
|
||||
group: "v1",
|
||||
group: "",
|
||||
namespaced: false,
|
||||
},
|
||||
persistentvolumeclaims: {
|
||||
kind: "PersistentVolumeClaim",
|
||||
group: "v1",
|
||||
group: "",
|
||||
namespaced: true,
|
||||
},
|
||||
pods: {
|
||||
kind: "Pod",
|
||||
group: "v1",
|
||||
group: "",
|
||||
namespaced: true,
|
||||
},
|
||||
poddisruptionbudgets: {
|
||||
@@ -159,7 +163,7 @@ export const apiResourceRecord: Record<KubeResource, KubeApiResourceData> = {
|
||||
},
|
||||
resourcequotas: {
|
||||
kind: "ResourceQuota",
|
||||
group: "v1",
|
||||
group: "",
|
||||
namespaced: true,
|
||||
},
|
||||
replicasets: {
|
||||
@@ -179,17 +183,17 @@ export const apiResourceRecord: Record<KubeResource, KubeApiResourceData> = {
|
||||
},
|
||||
secrets: {
|
||||
kind: "Secret",
|
||||
group: "v1",
|
||||
group: "",
|
||||
namespaced: true,
|
||||
},
|
||||
serviceaccounts: {
|
||||
kind: "ServiceAccount",
|
||||
group: "v1",
|
||||
group: "",
|
||||
namespaced: true,
|
||||
},
|
||||
services: {
|
||||
kind: "Service",
|
||||
group: "v1",
|
||||
group: "",
|
||||
namespaced: true,
|
||||
},
|
||||
statefulsets: {
|
||||
|
||||
Reference in new issue
Block a user