Fix accessible namespaces functionality under restrictive RBAC (#2138)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen authored and GitHub committed 2021-02-12 14:25:17 +02:00
1 parent d40bd0c7d0
commit 317c4cf072
2 files changed
+18 -1

No files matched your search

+2
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();
}
+16 -1
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[] {