1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/features/user-mode.ts
Roman 5670312c47
Migrating Vue components to React and stores refactoring (#585)
Signed-off-by: Roman <ixrock@gmail.com>

Co-authored-by: Sebastian Malton <sebastian@malton.name>
Co-authored-by: Sebastian Malton <smalton@mirantis.com>
Co-authored-by: Lauri Nevala <lauri.nevala@gmail.com>
Co-authored-by: Alex Andreev <alex.andreev.email@gmail.com>
2020-08-20 08:53:07 +03:00

45 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Feature, FeatureStatus } from "../main/feature"
import {KubeConfig, RbacAuthorizationV1Api} from "@kubernetes/client-node"
import { Cluster } from "../main/cluster"
export class UserModeFeature extends Feature {
static id = 'user-mode'
name = UserModeFeature.id;
latestVersion = "v2.0.0"
async install(cluster: Cluster): Promise<void> {
return super.install(cluster)
}
async upgrade(cluster: Cluster): Promise<void> {
return;
}
async featureStatus(kc: KubeConfig): Promise<FeatureStatus> {
const client = kc.makeApiClient(RbacAuthorizationV1Api)
const status: FeatureStatus = {
currentVersion: null,
installed: false,
latestVersion: this.latestVersion,
canUpgrade: false, // Dunno yet
};
try {
await client.readClusterRoleBinding("lens-user")
status.installed = true;
status.currentVersion = this.latestVersion;
status.canUpgrade = false;
} catch {
// ignore error
}
return status;
}
async uninstall(cluster: Cluster): Promise<void> {
const rbacClient = cluster.getProxyKubeconfig().makeApiClient(RbacAuthorizationV1Api)
await rbacClient.deleteClusterRole("lens-user");
await rbacClient.deleteClusterRoleBinding("lens-user");
}
}