Allow extensions to define cluster features (#1125)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen authored and GitHub committed 2020-10-26 08:21:22 +02:00
1 parent f3a0059355
commit 62ae7771df
81 files changed
+4069 -510

No files matched your search

+7 -21
View File
@@ -2,6 +2,7 @@ import { createIpcChannel } from "./ipc";
import { ClusterId, clusterStore } from "./cluster-store";
import { extensionLoader } from "../extensions/extension-loader"
import { appEventBus } from "./event-bus"
import { ResourceApplier } from "../main/resource-applier";
export const clusterIpc = {
activate: createIpcChannel({
@@ -42,32 +43,17 @@ export const clusterIpc = {
},
}),
installFeature: createIpcChannel({
channel: "cluster:install-feature",
handle: async (clusterId: ClusterId, feature: string, config?: any) => {
appEventBus.emit({name: "cluster", action: "install", params: { feature: feature}})
kubectlApplyAll: createIpcChannel({
channel: "cluster:kubectl-apply-all",
handle: (clusterId: ClusterId, resources: string[]) => {
appEventBus.emit({name: "cluster", action: "kubectl-apply-all"})
const cluster = clusterStore.getById(clusterId);
if (cluster) {
await cluster.installFeature(feature, config)
const applier = new ResourceApplier(cluster)
applier.kubectlApplyAll(resources)
} else {
throw `${clusterId} is not a valid cluster id`;
}
}
}),
uninstallFeature: createIpcChannel({
channel: "cluster:uninstall-feature",
handle: (clusterId: ClusterId, feature: string) => {
appEventBus.emit({name: "cluster", action: "uninstall", params: { feature: feature}})
return clusterStore.getById(clusterId)?.uninstallFeature(feature)
}
}),
upgradeFeature: createIpcChannel({
channel: "cluster:upgrade-feature",
handle: (clusterId: ClusterId, feature: string, config?: any) => {
appEventBus.emit({name: "cluster", action: "upgrade", params: { feature: feature}})
return clusterStore.getById(clusterId)?.upgradeFeature(feature, config)
}
}),
}