mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
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>
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
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");
|
||
}
|
||
}
|