mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add connect/disconnect methods to KubernetesCluster kind (#2758)
* add connect/disconnect methods to kubernetes cluster Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * return void Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
ef4bae341f
commit
b6b1b467e0
@ -21,11 +21,12 @@
|
|||||||
|
|
||||||
import { catalogCategoryRegistry } from "../catalog/catalog-category-registry";
|
import { catalogCategoryRegistry } from "../catalog/catalog-category-registry";
|
||||||
import { CatalogEntity, CatalogEntityActionContext, CatalogEntityAddMenuContext, CatalogEntityContextMenuContext, CatalogEntityMetadata, CatalogEntityStatus } from "../catalog";
|
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 { ClusterStore } from "../cluster-store";
|
||||||
import { requestMain } from "../ipc";
|
import { requestMain } from "../ipc";
|
||||||
import { productName } from "../vars";
|
import { productName } from "../vars";
|
||||||
import { CatalogCategory, CatalogCategorySpec } from "../catalog";
|
import { CatalogCategory, CatalogCategorySpec } from "../catalog";
|
||||||
|
import { app } from "electron";
|
||||||
|
|
||||||
export type KubernetesClusterSpec = {
|
export type KubernetesClusterSpec = {
|
||||||
kubeconfigPath: string;
|
kubeconfigPath: string;
|
||||||
@ -40,6 +41,38 @@ export class KubernetesCluster extends CatalogEntity<CatalogEntityMetadata, Kube
|
|||||||
public readonly apiVersion = "entity.k8slens.dev/v1alpha1";
|
public readonly apiVersion = "entity.k8slens.dev/v1alpha1";
|
||||||
public readonly kind = "KubernetesCluster";
|
public readonly kind = "KubernetesCluster";
|
||||||
|
|
||||||
|
async connect(): Promise<void> {
|
||||||
|
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<void> {
|
||||||
|
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) {
|
async onRun(context: CatalogEntityActionContext) {
|
||||||
context.navigate(`/cluster/${this.metadata.uid}`);
|
context.navigate(`/cluster/${this.metadata.uid}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user