mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
reverted cluster-manager.ts/getClusterForRequest()
Signed-off-by: Roman <ixrock@gmail.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
parent
f5a978ebf8
commit
22289570f7
@ -4,6 +4,7 @@ import { autorun } from "mobx";
|
|||||||
import { ClusterId, clusterStore } from "../common/cluster-store"
|
import { ClusterId, clusterStore } from "../common/cluster-store"
|
||||||
import { Cluster } from "./cluster"
|
import { Cluster } from "./cluster"
|
||||||
import logger from "./logger";
|
import logger from "./logger";
|
||||||
|
import { apiKubePrefix } from "../common/vars";
|
||||||
|
|
||||||
export class ClusterManager {
|
export class ClusterManager {
|
||||||
constructor(public readonly port: number) {
|
constructor(public readonly port: number) {
|
||||||
@ -42,8 +43,23 @@ export class ClusterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getClusterForRequest(req: http.IncomingMessage): Cluster {
|
getClusterForRequest(req: http.IncomingMessage): Cluster {
|
||||||
logger.debug(`getClusterForRequest(): ${req.headers.host}${req.url}`)
|
let cluster: Cluster = null
|
||||||
const clusterId = req.headers.host.split(".")[0]
|
|
||||||
return this.getCluster(clusterId)
|
// lens-server is connecting to 127.0.0.1:<port>/<uid>
|
||||||
|
if (req.headers.host.startsWith("127.0.0.1")) {
|
||||||
|
const clusterId = req.url.split("/")[1]
|
||||||
|
if (clusterId) {
|
||||||
|
cluster = this.getCluster(clusterId)
|
||||||
|
if (cluster) {
|
||||||
|
// we need to swap path prefix so that request is proxied to kube api
|
||||||
|
req.url = req.url.replace(`/${clusterId}`, apiKubePrefix)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const id = req.headers.host.split(".")[0]
|
||||||
|
cluster = this.getCluster(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cluster;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user