mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
redid changes after large refactor on master (#4688)
Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
parent
23c38b1f4e
commit
6cba82c491
@ -14,11 +14,10 @@ export class PortForwardRoute {
|
||||
const { namespace, resourceType, resourceName } = params;
|
||||
const port = Number(query.get("port"));
|
||||
const forwardPort = Number(query.get("forwardPort"));
|
||||
const protocol = query.get("protocol");
|
||||
|
||||
const portForward = PortForward.getPortforward({
|
||||
clusterId: cluster.id, kind: resourceType, name: resourceName,
|
||||
namespace, port, forwardPort, protocol,
|
||||
namespace, port, forwardPort,
|
||||
});
|
||||
|
||||
respondJson(response, { port: portForward?.forwardPort ?? null });
|
||||
|
||||
@ -16,7 +16,6 @@ export interface PortForwardArgs {
|
||||
name: string;
|
||||
port: number;
|
||||
forwardPort: number;
|
||||
protocol?: string;
|
||||
}
|
||||
|
||||
interface Dependencies {
|
||||
@ -32,8 +31,7 @@ export class PortForward {
|
||||
pf.kind == forward.kind &&
|
||||
pf.name == forward.name &&
|
||||
pf.namespace == forward.namespace &&
|
||||
pf.port == forward.port &&
|
||||
(!forward.protocol || pf.protocol == forward.protocol)
|
||||
pf.port == forward.port
|
||||
));
|
||||
}
|
||||
|
||||
@ -44,7 +42,6 @@ export class PortForward {
|
||||
public name: string;
|
||||
public port: number;
|
||||
public forwardPort: number;
|
||||
public protocol: string;
|
||||
|
||||
constructor(private dependencies: Dependencies, public pathToKubeConfig: string, args: PortForwardArgs) {
|
||||
this.clusterId = args.clusterId;
|
||||
@ -53,7 +50,6 @@ export class PortForward {
|
||||
this.name = args.name;
|
||||
this.port = args.port;
|
||||
this.forwardPort = args.forwardPort;
|
||||
this.protocol = args.protocol ?? "http";
|
||||
}
|
||||
|
||||
public async start() {
|
||||
|
||||
@ -18,7 +18,6 @@ export const routePortForward =
|
||||
const { namespace, resourceType, resourceName } = params;
|
||||
const port = Number(query.get("port"));
|
||||
const forwardPort = Number(query.get("forwardPort"));
|
||||
const protocol = query.get("protocol");
|
||||
|
||||
try {
|
||||
let portForward = PortForward.getPortforward({
|
||||
@ -28,7 +27,6 @@ export const routePortForward =
|
||||
namespace,
|
||||
port,
|
||||
forwardPort,
|
||||
protocol,
|
||||
});
|
||||
|
||||
if (!portForward) {
|
||||
@ -46,7 +44,6 @@ export const routePortForward =
|
||||
name: resourceName,
|
||||
port,
|
||||
forwardPort: thePort,
|
||||
protocol,
|
||||
});
|
||||
|
||||
const started = await portForward.start();
|
||||
|
||||
@ -273,11 +273,9 @@ export class PortForwardStore extends ItemStore<PortForwardItem> {
|
||||
let response: PortForwardResult;
|
||||
|
||||
try {
|
||||
const protocol = pf.protocol ?? "http";
|
||||
|
||||
response = await apiBase.post<PortForwardResult>(
|
||||
`/pods/port-forward/${pf.namespace}/${pf.kind}/${pf.name}`,
|
||||
{ query: { port, forwardPort, protocol }},
|
||||
{ query: { port, forwardPort }},
|
||||
);
|
||||
|
||||
// expecting the received port to be the specified port, unless the specified port is 0, which indicates any available port is suitable
|
||||
@ -355,11 +353,11 @@ function portForwardsEqual(portForward: ForwardedPort) {
|
||||
}
|
||||
|
||||
async function getActivePortForward(portForward: ForwardedPort): Promise<ForwardedPort> {
|
||||
const { port, forwardPort, protocol } = portForward;
|
||||
const { port, forwardPort } = portForward;
|
||||
let response: PortForwardResult;
|
||||
|
||||
try {
|
||||
response = await apiBase.get<PortForwardResult>(`/pods/port-forward/${portForward.namespace}/${portForward.kind}/${portForward.name}`, { query: { port, forwardPort, protocol }});
|
||||
response = await apiBase.get<PortForwardResult>(`/pods/port-forward/${portForward.namespace}/${portForward.kind}/${portForward.name}`, { query: { port, forwardPort }});
|
||||
} catch (error) {
|
||||
logger.warn(`[PORT-FORWARD-STORE] Error getting active port-forward: ${error}`, portForward);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user