mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix circular dep
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
3cffaaab43
commit
a1254d9d85
@ -146,8 +146,11 @@ app.on("ready", async () => {
|
|||||||
filesystemStore.load(),
|
filesystemStore.load(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const lensProxy = LensProxy.createInstance(handleWsUpgrade);
|
const lensProxy = LensProxy.createInstance(
|
||||||
|
handleWsUpgrade,
|
||||||
|
req => ClusterManager.getInstance().getClusterForRequest(req),
|
||||||
|
);
|
||||||
|
|
||||||
ClusterManager.createInstance().init();
|
ClusterManager.createInstance().init();
|
||||||
KubeconfigSyncManager.createInstance();
|
KubeconfigSyncManager.createInstance();
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ import { Router } from "../router";
|
|||||||
import type { ContextHandler } from "../context-handler";
|
import type { ContextHandler } from "../context-handler";
|
||||||
import logger from "../logger";
|
import logger from "../logger";
|
||||||
import { Singleton } from "../../common/utils";
|
import { Singleton } from "../../common/utils";
|
||||||
import { ClusterManager } from "../cluster-manager";
|
import type { Cluster } from "../cluster";
|
||||||
|
|
||||||
type WSUpgradeHandler = (req: http.IncomingMessage, socket: net.Socket, head: Buffer) => void;
|
type WSUpgradeHandler = (req: http.IncomingMessage, socket: net.Socket, head: Buffer) => void;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ export class LensProxy extends Singleton {
|
|||||||
|
|
||||||
public port: number;
|
public port: number;
|
||||||
|
|
||||||
constructor(handleWsUpgrade: WSUpgradeHandler) {
|
constructor(handleWsUpgrade: WSUpgradeHandler, protected getClusterForRequest: (req: http.IncomingMessage) => Cluster | undefined) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
const proxy = this.createProxy();
|
const proxy = this.createProxy();
|
||||||
@ -104,7 +104,7 @@ export class LensProxy extends Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async handleProxyUpgrade(proxy: httpProxy, req: http.IncomingMessage, socket: net.Socket, head: Buffer) {
|
protected async handleProxyUpgrade(proxy: httpProxy, req: http.IncomingMessage, socket: net.Socket, head: Buffer) {
|
||||||
const cluster = ClusterManager.getInstance().getClusterForRequest(req);
|
const cluster = this.getClusterForRequest(req);
|
||||||
|
|
||||||
if (cluster) {
|
if (cluster) {
|
||||||
const proxyUrl = await cluster.contextHandler.resolveAuthProxyUrl() + req.url.replace(apiKubePrefix, "");
|
const proxyUrl = await cluster.contextHandler.resolveAuthProxyUrl() + req.url.replace(apiKubePrefix, "");
|
||||||
@ -220,7 +220,7 @@ export class LensProxy extends Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async handleRequest(proxy: httpProxy, req: http.IncomingMessage, res: http.ServerResponse) {
|
protected async handleRequest(proxy: httpProxy, req: http.IncomingMessage, res: http.ServerResponse) {
|
||||||
const cluster = ClusterManager.getInstance().getClusterForRequest(req);
|
const cluster = this.getClusterForRequest(req);
|
||||||
|
|
||||||
if (cluster) {
|
if (cluster) {
|
||||||
const proxyTarget = await this.getProxyTarget(req, cluster.contextHandler);
|
const proxyTarget = await this.getProxyTarget(req, cluster.contextHandler);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user