mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
split cluster to managed cluster
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
a731e66b18
commit
374f066b86
19 files changed
+608
-477
No files matched your search
+13
-12
@@ -3,6 +3,7 @@ import { ClusterId, clusterStore } from "./cluster-store";
|
||||
import { appEventBus } from "./event-bus"
|
||||
import { ResourceApplier } from "../main/resource-applier";
|
||||
import { ipcMain } from "electron";
|
||||
import { ClusterManager } from "../main/cluster-manager";
|
||||
|
||||
export const clusterActivateHandler = "cluster:activate"
|
||||
export const clusterSetFrameIdHandler = "cluster:set-frame-id"
|
||||
@@ -10,35 +11,35 @@ export const clusterRefreshHandler = "cluster:refresh"
|
||||
export const clusterDisconnectHandler = "cluster:disconnect"
|
||||
export const clusterKubectlApplyAllHandler = "cluster:kubectl-apply-all"
|
||||
|
||||
function getById(clusterId: ClusterId) {
|
||||
return ClusterManager.getInstance<ClusterManager>().getClusterById(clusterId)
|
||||
}
|
||||
|
||||
if (ipcMain) {
|
||||
handleRequest(clusterActivateHandler, (event, clusterId: ClusterId, force = false) => {
|
||||
const cluster = clusterStore.getById(clusterId);
|
||||
if (cluster) {
|
||||
return cluster.activate(force);
|
||||
}
|
||||
return getById(clusterId)?.activate(force);
|
||||
})
|
||||
|
||||
handleRequest(clusterSetFrameIdHandler, (event, clusterId: ClusterId, frameId?: number) => {
|
||||
const cluster = clusterStore.getById(clusterId);
|
||||
if (cluster) {
|
||||
if (frameId) cluster.frameId = frameId; // save cluster's webFrame.routingId to be able to send push-updates
|
||||
return cluster.pushState();
|
||||
const managedCluster = getById(clusterId);
|
||||
if (managedCluster) {
|
||||
if (frameId) managedCluster.cluster.frameId = frameId; // save cluster's webFrame.routingId to be able to send push-updates
|
||||
return managedCluster.cluster.pushState();
|
||||
}
|
||||
})
|
||||
|
||||
handleRequest(clusterRefreshHandler, (event, clusterId: ClusterId) => {
|
||||
const cluster = clusterStore.getById(clusterId);
|
||||
if (cluster) return cluster.refresh({ refreshMetadata: true })
|
||||
getById(clusterId)?.refresh({ refreshMetadata: true });
|
||||
})
|
||||
|
||||
handleRequest(clusterDisconnectHandler, (event, clusterId: ClusterId) => {
|
||||
appEventBus.emit({name: "cluster", action: "stop"});
|
||||
return clusterStore.getById(clusterId)?.disconnect();
|
||||
return getById(clusterId)?.disconnect();
|
||||
})
|
||||
|
||||
handleRequest(clusterKubectlApplyAllHandler, (event, clusterId: ClusterId, resources: string[]) => {
|
||||
appEventBus.emit({name: "cluster", action: "kubectl-apply-all"})
|
||||
const cluster = clusterStore.getById(clusterId);
|
||||
const cluster = getById(clusterId);
|
||||
if (cluster) {
|
||||
const applier = new ResourceApplier(cluster)
|
||||
applier.kubectlApplyAll(resources)
|
||||
|
||||
Reference in new issue
Block a user