1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/main/feature-manager.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.5 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 { KubeConfig } from "@kubernetes/client-node"
import logger from "./logger";
import { Cluster } from "./cluster";
import { Feature, FeatureStatusMap, FeatureMap } from "./feature"
import { MetricsFeature } from "../features/metrics"
import { UserModeFeature } from "../features/user-mode"
const ALL_FEATURES: Map<string, Feature> = new Map([
[MetricsFeature.id, new MetricsFeature(null)],
[UserModeFeature.id, new UserModeFeature(null)],
]);
export async function getFeatures(cluster: Cluster): Promise<FeatureStatusMap> {
const result: FeatureStatusMap = {};
logger.debug(`features for ${cluster.contextName}`);
for (const [key, feature] of ALL_FEATURES) {
logger.debug(`feature ${key}`);
logger.debug("getting feature status...");
const kc = new KubeConfig();
kc.loadFromFile(cluster.getProxyKubeconfigPath());
result[feature.name] = await feature.featureStatus(kc);
}
logger.debug(`getFeatures resolving with features: ${JSON.stringify(result)}`);
return result;
}
export async function installFeature(name: string, cluster: Cluster, config: any): Promise<void> {
// TODO Figure out how to handle config stuff
return ALL_FEATURES.get(name).install(cluster)
}
export async function upgradeFeature(name: string, cluster: Cluster, config: any): Promise<void> {
// TODO Figure out how to handle config stuff
return ALL_FEATURES.get(name).upgrade(cluster)
}
export async function uninstallFeature(name: string, cluster: Cluster): Promise<void> {
return ALL_FEATURES.get(name).uninstall(cluster)
}