From b6b1b467e0abd79f6478fb85d8a658a0459c0617 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Tue, 18 May 2021 13:42:33 +0300 Subject: [PATCH] Add connect/disconnect methods to KubernetesCluster kind (#2758) * add connect/disconnect methods to kubernetes cluster Signed-off-by: Jari Kolehmainen * return void Signed-off-by: Jari Kolehmainen --- .../catalog-entities/kubernetes-cluster.ts | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/common/catalog-entities/kubernetes-cluster.ts b/src/common/catalog-entities/kubernetes-cluster.ts index cd217d3a02..7c6727ada5 100644 --- a/src/common/catalog-entities/kubernetes-cluster.ts +++ b/src/common/catalog-entities/kubernetes-cluster.ts @@ -21,11 +21,12 @@ import { catalogCategoryRegistry } from "../catalog/catalog-category-registry"; import { CatalogEntity, CatalogEntityActionContext, CatalogEntityAddMenuContext, CatalogEntityContextMenuContext, CatalogEntityMetadata, CatalogEntityStatus } from "../catalog"; -import { clusterDisconnectHandler } from "../cluster-ipc"; +import { clusterActivateHandler, clusterDisconnectHandler } from "../cluster-ipc"; import { ClusterStore } from "../cluster-store"; import { requestMain } from "../ipc"; import { productName } from "../vars"; import { CatalogCategory, CatalogCategorySpec } from "../catalog"; +import { app } from "electron"; export type KubernetesClusterSpec = { kubeconfigPath: string; @@ -40,6 +41,38 @@ export class KubernetesCluster extends CatalogEntity { + if (app) { + const cluster = ClusterStore.getInstance().getById(this.metadata.uid); + + if (!cluster) return; + + await cluster.activate(); + + return; + } + + await requestMain(clusterActivateHandler, this.metadata.uid, false); + + return; + } + + async disconnect(): Promise { + if (app) { + const cluster = ClusterStore.getInstance().getById(this.metadata.uid); + + if (!cluster) return; + + cluster.disconnect(); + + return; + } + + await requestMain(clusterDisconnectHandler, this.metadata.uid, false); + + return; + } + async onRun(context: CatalogEntityActionContext) { context.navigate(`/cluster/${this.metadata.uid}`); }