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

Fix accessible namespaces functionality under restrictive RBAC (#2138)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-02-12 14:25:17 +02:00 committed by GitHub
parent d40bd0c7d0
commit 317c4cf072
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -399,6 +399,8 @@ export class Cluster implements ClusterModel, ClusterState {
this.accessible = false;
this.ready = false;
this.activated = false;
this.allowedNamespaces = [];
this.accessibleNamespaces = [];
this.resourceAccessStatuses.clear();
this.pushState();
}

View File

@ -14,7 +14,22 @@ export const clusterContext: ClusterContext = {
},
get allNamespaces(): string[] {
return this.cluster?.allowedNamespaces ?? [];
if (!this.cluster) {
return [];
}
// user given list of namespaces
if (this.cluster?.accessibleNamespaces.length) {
return this.cluster.accessibleNamespaces;
}
if (namespaceStore.items.length > 0) {
// namespaces from kubernetes api
return namespaceStore.items.map((namespace) => namespace.getName());
} else {
// fallback to cluster resolved namespaces because we could not load list
return this.cluster.allowedNamespaces || [];
}
},
get contextNamespaces(): string[] {