Merge branch 'master' into feature/command-palette

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen committed 2021-01-26 07:35:49 +02:00
commit 8a8ce3e692
124 files changed
+758 -485

No files matched your search

@@ -31,4 +31,4 @@ export class BaseClusterDetector {
},
});
}
}
}
@@ -23,4 +23,4 @@ export class ClusterIdDetector extends BaseClusterDetector {
return response.metadata.uid;
}
}
}
@@ -48,4 +48,4 @@ detectorRegistry.add(ClusterIdDetector);
detectorRegistry.add(LastSeenDetector);
detectorRegistry.add(VersionDetector);
detectorRegistry.add(DistributionDetector);
detectorRegistry.add(NodesCountDetector);
detectorRegistry.add(NodesCountDetector);
@@ -11,4 +11,4 @@ export class LastSeenDetector extends BaseClusterDetector {
return { value: new Date().toJSON(), accuracy: 100 };
}
}
}
@@ -16,4 +16,4 @@ export class NodesCountDetector extends BaseClusterDetector {
return response.items.length;
}
}
}
@@ -16,4 +16,4 @@ export class VersionDetector extends BaseClusterDetector {
return response.gitVersion;
}
}
}
+29 -12
View File
@@ -190,7 +190,7 @@ export class Cluster implements ClusterModel, ClusterState {
*/
@observable metadata: ClusterMetadata = {};
/**
* List of allowed namespaces
* List of allowed namespaces verified via K8S::SelfSubjectAccessReview api
*
* @observable
*/
@@ -203,7 +203,7 @@ export class Cluster implements ClusterModel, ClusterState {
*/
@observable allowedResources: string[] = [];
/**
* List of accessible namespaces
* List of accessible namespaces provided by user in the Cluster Settings
*
* @observable
*/
@@ -224,7 +224,7 @@ export class Cluster implements ClusterModel, ClusterState {
* @computed
*/
@computed get name() {
return this.preferences.clusterName || this.contextName;
return this.preferences.clusterName || this.contextName;
}
/**
@@ -279,7 +279,8 @@ export class Cluster implements ClusterModel, ClusterState {
* @param port port where internal auth proxy is listening
* @internal
*/
@action async init(port: number) {
@action
async init(port: number) {
try {
this.initializing = true;
this.contextHandler = new ContextHandler(this);
@@ -334,7 +335,8 @@ export class Cluster implements ClusterModel, ClusterState {
* @param force force activation
* @internal
*/
@action async activate(force = false) {
@action
async activate(force = false) {
if (this.activated && !force) {
return this.pushState();
}
@@ -373,7 +375,8 @@ export class Cluster implements ClusterModel, ClusterState {
/**
* @internal
*/
@action async reconnect() {
@action
async reconnect() {
logger.info(`[CLUSTER]: reconnect`, this.getMeta());
this.contextHandler?.stopServer();
await this.contextHandler?.ensureServer();
@@ -400,7 +403,8 @@ export class Cluster implements ClusterModel, ClusterState {
* @internal
* @param opts refresh options
*/
@action async refresh(opts: ClusterRefreshOptions = {}) {
@action
async refresh(opts: ClusterRefreshOptions = {}) {
logger.info(`[CLUSTER]: refresh`, this.getMeta());
await this.whenInitialized;
await this.refreshConnectionStatus();
@@ -420,7 +424,8 @@ export class Cluster implements ClusterModel, ClusterState {
/**
* @internal
*/
@action async refreshMetadata() {
@action
async refreshMetadata() {
logger.info(`[CLUSTER]: refreshMetadata`, this.getMeta());
const metadata = await detectorRegistry.detectForCluster(this);
const existingMetadata = this.metadata;
@@ -431,7 +436,8 @@ export class Cluster implements ClusterModel, ClusterState {
/**
* @internal
*/
@action async refreshConnectionStatus() {
@action
async refreshConnectionStatus() {
const connectionStatus = await this.getConnectionStatus();
this.online = connectionStatus > ClusterStatus.Offline;
@@ -441,7 +447,8 @@ export class Cluster implements ClusterModel, ClusterState {
/**
* @internal
*/
@action async refreshAllowedResources() {
@action
async refreshAllowedResources() {
this.allowedNamespaces = await this.getAllowedNamespaces();
this.allowedResources = await this.getAllowedResources();
}
@@ -668,7 +675,7 @@ export class Cluster implements ClusterModel, ClusterState {
for (const namespace of this.allowedNamespaces.slice(0, 10)) {
if (!this.resourceAccessStatuses.get(apiResource)) {
const result = await this.canI({
resource: apiResource.resource,
resource: apiResource.apiName,
group: apiResource.group,
verb: "list",
namespace
@@ -683,9 +690,19 @@ export class Cluster implements ClusterModel, ClusterState {
return apiResources
.filter((resource) => this.resourceAccessStatuses.get(resource))
.map(apiResource => apiResource.resource);
.map(apiResource => apiResource.apiName);
} catch (error) {
return [];
}
}
isAllowedResource(kind: string): boolean {
const apiResource = apiResources.find(resource => resource.kind === kind || resource.apiName === kind);
if (apiResource) {
return this.allowedResources.includes(apiResource.apiName);
}
return true; // allowed by default for other resources
}
}