mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
tweak KubeAuthProxy.run() return behaviour
Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
parent
1b399fab01
commit
584021d094
@ -67,53 +67,53 @@ export class KubeAuthProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async run(): Promise<void> {
|
public async run(): Promise<void> {
|
||||||
if (!this.proxyProcess) {
|
if (this.proxyProcess) {
|
||||||
const proxyBin = await this.kubectl.getPath();
|
return this.whenReady;
|
||||||
const args = [
|
|
||||||
"proxy",
|
|
||||||
"-p", "0",
|
|
||||||
"--kubeconfig", `${this.cluster.kubeConfigPath}`,
|
|
||||||
"--context", `${this.cluster.contextName}`,
|
|
||||||
"--accept-hosts", this.acceptHosts,
|
|
||||||
"--reject-paths", "^[^/]"
|
|
||||||
];
|
|
||||||
|
|
||||||
if (process.env.DEBUG_PROXY === "true") {
|
|
||||||
args.push("-v", "9");
|
|
||||||
}
|
|
||||||
logger.debug(`spawning kubectl proxy with args: ${args}`);
|
|
||||||
|
|
||||||
this.proxyProcess = spawn(proxyBin, args, { env: this.env, });
|
|
||||||
this.proxyProcess.on("error", (error) => {
|
|
||||||
this.sendIpcLogMessage({ data: error.message, error: true });
|
|
||||||
this.exit();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.proxyProcess.on("exit", (code) => {
|
|
||||||
this.sendIpcLogMessage({ data: `proxy exited with code: ${code}`, error: code > 0 });
|
|
||||||
this.exit();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.proxyProcess.stderr.on("data", (data) => {
|
|
||||||
this.lastError = this.parseError(data.toString());
|
|
||||||
this.sendIpcLogMessage({ data: data.toString(), error: true });
|
|
||||||
});
|
|
||||||
|
|
||||||
this._port = await getPortFrom(this.proxyProcess.stdout, {
|
|
||||||
lineRegex: startingServeRegex,
|
|
||||||
onFind: () => this.sendIpcLogMessage({ data: "Authentication proxy started\n" }),
|
|
||||||
});
|
|
||||||
|
|
||||||
this.proxyProcess.stdout.on("data", (data: any) => {
|
|
||||||
this.sendIpcLogMessage({ data: data.toString() });
|
|
||||||
});
|
|
||||||
|
|
||||||
await waitUntilUsed(this.port, 500, 10000);
|
|
||||||
|
|
||||||
this.ready = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.whenReady;
|
const proxyBin = await this.kubectl.getPath();
|
||||||
|
const args = [
|
||||||
|
"proxy",
|
||||||
|
"-p", "0",
|
||||||
|
"--kubeconfig", `${this.cluster.kubeConfigPath}`,
|
||||||
|
"--context", `${this.cluster.contextName}`,
|
||||||
|
"--accept-hosts", this.acceptHosts,
|
||||||
|
"--reject-paths", "^[^/]"
|
||||||
|
];
|
||||||
|
|
||||||
|
if (process.env.DEBUG_PROXY === "true") {
|
||||||
|
args.push("-v", "9");
|
||||||
|
}
|
||||||
|
logger.debug(`spawning kubectl proxy with args: ${args}`);
|
||||||
|
|
||||||
|
this.proxyProcess = spawn(proxyBin, args, { env: this.env, });
|
||||||
|
this.proxyProcess.on("error", (error) => {
|
||||||
|
this.sendIpcLogMessage({ data: error.message, error: true });
|
||||||
|
this.exit();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.proxyProcess.on("exit", (code) => {
|
||||||
|
this.sendIpcLogMessage({ data: `proxy exited with code: ${code}`, error: code > 0 });
|
||||||
|
this.exit();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.proxyProcess.stderr.on("data", (data) => {
|
||||||
|
this.lastError = this.parseError(data.toString());
|
||||||
|
this.sendIpcLogMessage({ data: data.toString(), error: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
this._port = await getPortFrom(this.proxyProcess.stdout, {
|
||||||
|
lineRegex: startingServeRegex,
|
||||||
|
onFind: () => this.sendIpcLogMessage({ data: "Authentication proxy started\n" }),
|
||||||
|
});
|
||||||
|
|
||||||
|
this.proxyProcess.stdout.on("data", (data: any) => {
|
||||||
|
this.sendIpcLogMessage({ data: data.toString() });
|
||||||
|
});
|
||||||
|
|
||||||
|
await waitUntilUsed(this.port, 500, 10000);
|
||||||
|
|
||||||
|
this.ready = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected parseError(data: string) {
|
protected parseError(data: string) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user