1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Start authentication proxy when opening cluster settings (#1063)

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala 2020-10-12 10:10:30 +03:00 committed by GitHub
parent dc07d646ec
commit daa4992f2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 11 deletions

View File

@ -5,11 +5,10 @@ import { tracker } from "./tracker";
export const clusterIpc = { export const clusterIpc = {
activate: createIpcChannel({ activate: createIpcChannel({
channel: "cluster:activate", channel: "cluster:activate",
handle: (clusterId: ClusterId, frameId?: number) => { handle: (clusterId: ClusterId, force = false) => {
const cluster = clusterStore.getById(clusterId); const cluster = clusterStore.getById(clusterId);
if (cluster) { if (cluster) {
if (frameId) cluster.frameId = frameId; // save cluster's webFrame.routingId to be able to send push-updates return cluster.activate(force);
return cluster.activate();
} }
}, },
}), }),

View File

@ -46,6 +46,7 @@ export class Cluster implements ClusterModel {
public contextHandler: ContextHandler; public contextHandler: ContextHandler;
protected kubeconfigManager: KubeconfigManager; protected kubeconfigManager: KubeconfigManager;
protected eventDisposers: Function[] = []; protected eventDisposers: Function[] = [];
protected activated = false;
whenInitialized = when(() => this.initialized); whenInitialized = when(() => this.initialized);
whenReady = when(() => this.ready); whenReady = when(() => this.ready);
@ -126,7 +127,10 @@ export class Cluster implements ClusterModel {
} }
@action @action
async activate() { async activate(force = false ) {
if (this.activated && !force) {
return this.pushState();
}
logger.info(`[CLUSTER]: activate`, this.getMeta()); logger.info(`[CLUSTER]: activate`, this.getMeta());
await this.whenInitialized; await this.whenInitialized;
if (!this.eventDisposers.length) { if (!this.eventDisposers.length) {
@ -142,6 +146,7 @@ export class Cluster implements ClusterModel {
this.kubeCtl = new Kubectl(this.version) this.kubeCtl = new Kubectl(this.version)
this.kubeCtl.ensureKubectl() // download kubectl in background, so it's not blocking dashboard this.kubeCtl.ensureKubectl() // download kubectl in background, so it's not blocking dashboard
} }
this.activated = true
return this.pushState(); return this.pushState();
} }
@ -162,6 +167,7 @@ export class Cluster implements ClusterModel {
this.online = false; this.online = false;
this.accessible = false; this.accessible = false;
this.ready = false; this.ready = false;
this.activated = false;
this.pushState(); this.pushState();
} }
@ -184,9 +190,7 @@ export class Cluster implements ClusterModel {
this.refreshEvents(), this.refreshEvents(),
this.refreshAllowedResources(), this.refreshAllowedResources(),
]); ]);
if (!this.ready) { this.ready = true
this.ready = true
}
} }
this.pushState(); this.pushState();
} }

View File

@ -46,8 +46,9 @@ export class ClusterSettings extends React.Component<Props> {
} }
} }
refreshCluster = () => { refreshCluster = async () => {
if(this.cluster) { if(this.cluster) {
await clusterIpc.activate.invokeFromRenderer(this.cluster.id);
clusterIpc.refresh.invokeFromRenderer(this.cluster.id); clusterIpc.refresh.invokeFromRenderer(this.cluster.id);
} }
} }

View File

@ -47,13 +47,14 @@ export class ClusterStatus extends React.Component<Props> {
ipcRenderer.removeAllListeners(`kube-auth:${this.props.clusterId}`); ipcRenderer.removeAllListeners(`kube-auth:${this.props.clusterId}`);
} }
activateCluster = async () => { activateCluster = async (force = false) => {
await clusterIpc.activate.invokeFromRenderer(this.props.clusterId); await clusterIpc.activate.invokeFromRenderer(this.props.clusterId, force);
} }
reconnect = async () => { reconnect = async () => {
this.authOutput = []
this.isReconnecting = true; this.isReconnecting = true;
await this.activateCluster(); await this.activateCluster(true);
this.isReconnecting = false; this.isReconnecting = false;
} }