mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Use new ordering to make openNodeShellSession non-special
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
c850fb6211
commit
534e86c3f5
@ -5,7 +5,7 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { apiKubePrefix } from "../vars";
|
||||
import isDebuggingInjectable from "../vars/is-debugging.injectable";
|
||||
import apiBaseInjectable from "./api-base.injectable";
|
||||
import { apiBaseHostHeaderInjectionToken, apiBaseServerAddressInjectionToken } from "./api-base-configs";
|
||||
import createKubeJsonApiInjectable from "./create-kube-json-api.injectable";
|
||||
import type { KubeJsonApi } from "./kube-json-api";
|
||||
|
||||
@ -14,19 +14,18 @@ export type CreateKubeJsonApiForCluster = (clusterId: string) => KubeJsonApi;
|
||||
const createKubeJsonApiForClusterInjectable = getInjectable({
|
||||
id: "create-kube-json-api-for-cluster",
|
||||
instantiate: (di): CreateKubeJsonApiForCluster => {
|
||||
const apiBase = di.inject(apiBaseInjectable);
|
||||
const createKubeJsonApi = di.inject(createKubeJsonApiInjectable);
|
||||
const isDebugging = di.inject(isDebuggingInjectable);
|
||||
|
||||
return (clusterId) => createKubeJsonApi(
|
||||
{
|
||||
serverAddress: apiBase.config.serverAddress,
|
||||
serverAddress: di.inject(apiBaseServerAddressInjectionToken),
|
||||
apiBase: apiKubePrefix,
|
||||
debug: isDebugging,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"Host": `${clusterId}.localhost:${new URL(apiBase.config.serverAddress).port}`,
|
||||
"Host": `${clusterId}.${di.inject(apiBaseHostHeaderInjectionToken)}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
@ -22,10 +22,11 @@ const openShellSessionInjectable = getInjectable({
|
||||
|
||||
instantiate: (di): OpenShellSession => {
|
||||
const openLocalShellSession = di.inject(openLocalShellSessionInjectable);
|
||||
const openNodeShellSession = di.inject(openNodeShellSessionInjectable);
|
||||
|
||||
return ({ nodeName, ...args }) => (
|
||||
nodeName
|
||||
? di.inject(openNodeShellSessionInjectable, { nodeName, ...args })
|
||||
? openNodeShellSession({ nodeName, ...args })
|
||||
: openLocalShellSession(args)
|
||||
);
|
||||
},
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import type WebSocket from "ws";
|
||||
import createKubectlInjectable from "../../kubectl/create-kubectl.injectable";
|
||||
@ -27,9 +27,11 @@ export interface NodeShellSessionArgs {
|
||||
nodeName: string;
|
||||
}
|
||||
|
||||
export type OpenNodeShellSession = (args: NodeShellSessionArgs) => Promise<void>;
|
||||
|
||||
const openNodeShellSessionInjectable = getInjectable({
|
||||
id: "open-node-shell-session",
|
||||
instantiate: (di, params: NodeShellSessionArgs) => {
|
||||
instantiate: (di): OpenNodeShellSession => {
|
||||
const createKubectl = di.inject(createKubectlInjectable);
|
||||
const dependencies: NodeShellSessionDependencies = {
|
||||
isMac: di.inject(isMacInjectable),
|
||||
@ -44,13 +46,14 @@ const openNodeShellSessionInjectable = getInjectable({
|
||||
emitAppEvent: di.inject(emitAppEventInjectable),
|
||||
stat: di.inject(statInjectable),
|
||||
};
|
||||
const kubectl = createKubectl(params.cluster.version);
|
||||
const session = new NodeShellSession(dependencies, { kubectl, ...params });
|
||||
|
||||
return session.open();
|
||||
return async (args) => {
|
||||
const kubectl = createKubectl(args.cluster.version);
|
||||
const session = new NodeShellSession(dependencies, { kubectl, ...args });
|
||||
|
||||
return session.open();
|
||||
};
|
||||
},
|
||||
// NOTE: this must be transient to bypass the circular dependency of `createKubeJsonApiForClusterInjectable` on the lens proxy port
|
||||
lifecycle: lifecycleEnum.transient,
|
||||
});
|
||||
|
||||
export default openNodeShellSessionInjectable;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user