mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Switch main's route handlers to be static functions (#2712)
This commit is contained in:
1 parent
b373411a16
commit
f4ff28e51c
11 files changed
+173
-196
No files matched your search
@@ -1,11 +1,11 @@
|
||||
import { LensApiRequest } from "../router";
|
||||
import { LensApi } from "../lens-api";
|
||||
import { spawn, ChildProcessWithoutNullStreams } from "child_process";
|
||||
import { Kubectl } from "../kubectl";
|
||||
import { shell } from "electron";
|
||||
import * as tcpPortUsed from "tcp-port-used";
|
||||
import logger from "../logger";
|
||||
import { getPortFrom } from "../utils/get-port";
|
||||
import { respondJson } from "../utils/http-responses";
|
||||
|
||||
interface PortForwardArgs {
|
||||
clusterId: string;
|
||||
@@ -95,9 +95,8 @@ class PortForward {
|
||||
}
|
||||
}
|
||||
|
||||
class PortForwardRoute extends LensApi {
|
||||
|
||||
public async routePortForward(request: LensApiRequest) {
|
||||
export class PortForwardRoute {
|
||||
static async routePortForward(request: LensApiRequest) {
|
||||
const { params, response, cluster} = request;
|
||||
const { namespace, port, resourceType, resourceName } = params;
|
||||
let portForward = PortForward.getPortforward({
|
||||
@@ -117,18 +116,14 @@ class PortForwardRoute extends LensApi {
|
||||
const started = await portForward.start();
|
||||
|
||||
if (!started) {
|
||||
this.respondJson(response, {
|
||||
return respondJson(response, {
|
||||
message: "Failed to open port-forward"
|
||||
}, 400);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
portForward.open();
|
||||
|
||||
this.respondJson(response, {});
|
||||
respondJson(response, {});
|
||||
}
|
||||
}
|
||||
|
||||
export const portForwardRoute = new PortForwardRoute();
|
||||
Reference in new issue
Block a user