mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Update injectable library (#4842)
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>
This commit is contained in:
1 parent
e8ca1ddf87
commit
b65f6e00ec
231 files changed
+630
-613
No files matched your search
@@ -2,12 +2,12 @@
|
||||
* 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 electronAppInjectable from "../get-electron-app-path/electron-app/electron-app.injectable";
|
||||
|
||||
const appNameInjectable = getInjectable({
|
||||
id: "app-name",
|
||||
instantiate: (di) => di.inject(electronAppInjectable).name,
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default appNameInjectable;
|
||||
@@ -3,9 +3,8 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import {
|
||||
DependencyInjectionContainer,
|
||||
DiContainerForSetup,
|
||||
getInjectable,
|
||||
lifecycleEnum,
|
||||
} from "@ogre-tools/injectable";
|
||||
|
||||
import {
|
||||
@@ -22,38 +21,40 @@ import appNameInjectable from "./app-name/app-name.injectable";
|
||||
import directoryForIntegrationTestingInjectable from "./directory-for-integration-testing/directory-for-integration-testing.injectable";
|
||||
|
||||
const appPathsInjectable = getInjectable({
|
||||
setup: (di) => {
|
||||
const directoryForIntegrationTesting = di.inject(
|
||||
id: "app-paths",
|
||||
|
||||
setup: async (di) => {
|
||||
const directoryForIntegrationTesting = await di.inject(
|
||||
directoryForIntegrationTestingInjectable,
|
||||
);
|
||||
|
||||
if (directoryForIntegrationTesting) {
|
||||
setupPathForAppDataInIntegrationTesting(di, directoryForIntegrationTesting);
|
||||
await setupPathForAppDataInIntegrationTesting(di, directoryForIntegrationTesting);
|
||||
}
|
||||
|
||||
setupPathForUserData(di);
|
||||
registerAppPathsChannel(di);
|
||||
await setupPathForUserData(di);
|
||||
await registerAppPathsChannel(di);
|
||||
},
|
||||
|
||||
instantiate: (di) =>
|
||||
getAppPaths({ getAppPath: di.inject(getElectronAppPathInjectable) }),
|
||||
|
||||
injectionToken: appPathsInjectionToken,
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default appPathsInjectable;
|
||||
|
||||
const registerAppPathsChannel = (di: DependencyInjectionContainer) => {
|
||||
const registerChannel = di.inject(registerChannelInjectable);
|
||||
const registerAppPathsChannel = async (di: DiContainerForSetup) => {
|
||||
const registerChannel = await di.inject(registerChannelInjectable);
|
||||
const appPaths = await di.inject(appPathsInjectable);
|
||||
|
||||
registerChannel(appPathsIpcChannel, () => di.inject(appPathsInjectable));
|
||||
registerChannel(appPathsIpcChannel, () => appPaths);
|
||||
};
|
||||
|
||||
const setupPathForUserData = (di: DependencyInjectionContainer) => {
|
||||
const setElectronAppPath = di.inject(setElectronAppPathInjectable);
|
||||
const appName = di.inject(appNameInjectable);
|
||||
const getAppPath = di.inject(getElectronAppPathInjectable);
|
||||
const setupPathForUserData = async (di: DiContainerForSetup) => {
|
||||
const setElectronAppPath = await di.inject(setElectronAppPathInjectable);
|
||||
const appName = await di.inject(appNameInjectable);
|
||||
const getAppPath = await di.inject(getElectronAppPathInjectable);
|
||||
|
||||
const appDataPath = getAppPath("appData");
|
||||
|
||||
@@ -61,8 +62,8 @@ const setupPathForUserData = (di: DependencyInjectionContainer) => {
|
||||
};
|
||||
|
||||
// Todo: this kludge is here only until we have a proper place to setup integration testing.
|
||||
const setupPathForAppDataInIntegrationTesting = (di: DependencyInjectionContainer, appDataPath: string) => {
|
||||
const setElectronAppPath = di.inject(setElectronAppPathInjectable);
|
||||
const setupPathForAppDataInIntegrationTesting = async (di: DiContainerForSetup, appDataPath: string) => {
|
||||
const setElectronAppPath = await di.inject(setElectronAppPathInjectable);
|
||||
|
||||
setElectronAppPath("appData", appDataPath);
|
||||
};
|
||||
+2
-2
@@ -2,11 +2,11 @@
|
||||
* 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";
|
||||
|
||||
const directoryForIntegrationTestingInjectable = getInjectable({
|
||||
id: "directory-for-integration-testing",
|
||||
instantiate: () => process.env.CICD,
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default directoryForIntegrationTestingInjectable;
|
||||
@@ -2,12 +2,12 @@
|
||||
* 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 { app } from "electron";
|
||||
|
||||
const electronAppInjectable = getInjectable({
|
||||
id: "electron-app",
|
||||
instantiate: () => app,
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
* 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 electronAppInjectable from "./electron-app/electron-app.injectable";
|
||||
import { getElectronAppPath } from "./get-electron-app-path";
|
||||
|
||||
const getElectronAppPathInjectable = getInjectable({
|
||||
id: "get-electron-app-path",
|
||||
|
||||
instantiate: (di) =>
|
||||
getElectronAppPath({ app: di.inject(electronAppInjectable) }),
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default getElectronAppPathInjectable;
|
||||
@@ -2,12 +2,12 @@
|
||||
* 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 { ipcMain } from "electron";
|
||||
|
||||
const ipcMainInjectable = getInjectable({
|
||||
id: "ipc-main",
|
||||
instantiate: () => ipcMain,
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
* 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 ipcMainInjectable from "./ipc-main/ipc-main.injectable";
|
||||
import { registerChannel } from "./register-channel";
|
||||
|
||||
const registerChannelInjectable = getInjectable({
|
||||
id: "register-channel",
|
||||
|
||||
instantiate: (di) => registerChannel({
|
||||
ipcMain: di.inject(ipcMainInjectable),
|
||||
}),
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default registerChannelInjectable;
|
||||
@@ -2,15 +2,15 @@
|
||||
* 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 { PathName } from "../../../common/app-paths/app-path-names";
|
||||
import electronAppInjectable from "../get-electron-app-path/electron-app/electron-app.injectable";
|
||||
|
||||
const setElectronAppPathInjectable = getInjectable({
|
||||
id: "set-electron-app-path",
|
||||
|
||||
instantiate: (di) => (name: PathName, path: string) : void =>
|
||||
di.inject(electronAppInjectable).setPath(name, path),
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default setElectronAppPathInjectable;
|
||||
+3
-3
@@ -2,18 +2,18 @@
|
||||
* 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 directoryForKubeConfigsInjectable from "../../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable";
|
||||
import { KubeconfigSyncManager } from "./kubeconfig-sync-manager";
|
||||
import { createClusterInjectionToken } from "../../../common/cluster/create-cluster-injection-token";
|
||||
|
||||
const kubeconfigSyncManagerInjectable = getInjectable({
|
||||
id: "kubeconfig-sync-manager",
|
||||
|
||||
instantiate: (di) => new KubeconfigSyncManager({
|
||||
directoryForKubeConfigs: di.inject(directoryForKubeConfigsInjectable),
|
||||
createCluster: di.inject(createClusterInjectionToken),
|
||||
}),
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default kubeconfigSyncManagerInjectable;
|
||||
@@ -2,12 +2,14 @@
|
||||
* 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 { ContextHandler } from "./context-handler";
|
||||
import createKubeAuthProxyInjectable from "../kube-auth-proxy/create-kube-auth-proxy.injectable";
|
||||
|
||||
const createContextHandlerInjectable = getInjectable({
|
||||
id: "create-context-handler",
|
||||
|
||||
instantiate: (di) => {
|
||||
const dependencies = {
|
||||
createKubeAuthProxy: di.inject(createKubeAuthProxyInjectable),
|
||||
@@ -15,8 +17,6 @@ const createContextHandlerInjectable = getInjectable({
|
||||
|
||||
return (cluster: Cluster) => new ContextHandler(dependencies, cluster);
|
||||
},
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default createContextHandlerInjectable;
|
||||
@@ -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 { Cluster, ClusterDependencies } from "../../common/cluster/cluster";
|
||||
import directoryForKubeConfigsInjectable from "../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable";
|
||||
import createKubeconfigManagerInjectable from "../kubeconfig-manager/create-kubeconfig-manager.injectable";
|
||||
@@ -13,6 +13,8 @@ import authorizationReviewInjectable from "../../common/cluster/authorization-re
|
||||
import listNamespacesInjectable from "../../common/cluster/list-namespaces.injectable";
|
||||
|
||||
const createClusterInjectable = getInjectable({
|
||||
id: "create-cluster",
|
||||
|
||||
instantiate: (di) => {
|
||||
const dependencies: ClusterDependencies = {
|
||||
directoryForKubeConfigs: di.inject(directoryForKubeConfigsInjectable),
|
||||
@@ -27,8 +29,6 @@ const createClusterInjectable = getInjectable({
|
||||
},
|
||||
|
||||
injectionToken: createClusterInjectionToken,
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default createClusterInjectable;
|
||||
@@ -27,7 +27,6 @@ export const getDiForUnitTesting = (
|
||||
const injectableInstance = require(filePath).default;
|
||||
|
||||
di.register({
|
||||
id: filePath,
|
||||
...injectableInstance,
|
||||
aliases: [injectableInstance, ...(injectableInstance.aliases || [])],
|
||||
});
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
* 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 electronMenuItemsInjectable from "../../menu/electron-menu-items.injectable";
|
||||
import directoryForLensLocalStorageInjectable
|
||||
from "../../../common/directory-for-lens-local-storage/directory-for-lens-local-storage.injectable";
|
||||
import { initIpcMainHandlers } from "./init-ipc-main-handlers";
|
||||
|
||||
const initIpcMainHandlersInjectable = getInjectable({
|
||||
id: "init-ipc-main-handlers",
|
||||
|
||||
instantiate: (di) => initIpcMainHandlers({
|
||||
electronMenuItems: di.inject(electronMenuItemsInjectable),
|
||||
directoryForLensLocalStorage: di.inject(directoryForLensLocalStorageInjectable),
|
||||
}),
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default initIpcMainHandlersInjectable;
|
||||
@@ -2,12 +2,14 @@
|
||||
* 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 { KubeAuthProxy } from "./kube-auth-proxy";
|
||||
import type { Cluster } from "../../common/cluster/cluster";
|
||||
import bundledKubectlInjectable from "../kubectl/bundled-kubectl.injectable";
|
||||
|
||||
const createKubeAuthProxyInjectable = getInjectable({
|
||||
id: "create-kube-auth-proxy",
|
||||
|
||||
instantiate: (di) => {
|
||||
const bundledKubectl = di.inject(bundledKubectlInjectable);
|
||||
|
||||
@@ -18,8 +20,6 @@ const createKubeAuthProxyInjectable = getInjectable({
|
||||
return (cluster: Cluster, environmentVariables: NodeJS.ProcessEnv) =>
|
||||
new KubeAuthProxy(dependencies, cluster, environmentVariables);
|
||||
},
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default createKubeAuthProxyInjectable;
|
||||
@@ -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 directoryForTempInjectable from "../../common/app-paths/directory-for-temp/directory-for-temp.injectable";
|
||||
import { KubeconfigManager } from "./kubeconfig-manager";
|
||||
@@ -12,6 +12,8 @@ export interface KubeConfigManagerInstantiationParameter {
|
||||
}
|
||||
|
||||
const createKubeconfigManagerInjectable = getInjectable({
|
||||
id: "create-kubeconfig-manager",
|
||||
|
||||
instantiate: (di) => {
|
||||
const dependencies = {
|
||||
directoryForTemp: di.inject(directoryForTempInjectable),
|
||||
@@ -19,8 +21,6 @@ const createKubeconfigManagerInjectable = getInjectable({
|
||||
|
||||
return (cluster: Cluster) => new KubeconfigManager(dependencies, cluster);
|
||||
},
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default createKubeconfigManagerInjectable;
|
||||
@@ -2,11 +2,13 @@
|
||||
* 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 { getBundledKubectlVersion } from "../../common/utils";
|
||||
import createKubectlInjectable from "./create-kubectl.injectable";
|
||||
|
||||
const bundledKubectlInjectable = getInjectable({
|
||||
id: "bundled-kubectl",
|
||||
|
||||
instantiate: (di) => {
|
||||
const createKubectl = di.inject(createKubectlInjectable);
|
||||
|
||||
@@ -14,8 +16,6 @@ const bundledKubectlInjectable = getInjectable({
|
||||
|
||||
return createKubectl(bundledKubectlVersion);
|
||||
},
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default bundledKubectlInjectable;
|
||||
@@ -2,12 +2,14 @@
|
||||
* 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 { Kubectl } from "./kubectl";
|
||||
import directoryForKubectlBinariesInjectable from "./directory-for-kubectl-binaries/directory-for-kubectl-binaries.injectable";
|
||||
import userStoreInjectable from "../../common/user-store/user-store.injectable";
|
||||
|
||||
const createKubectlInjectable = getInjectable({
|
||||
id: "create-kubectl",
|
||||
|
||||
instantiate: (di) => {
|
||||
const dependencies = {
|
||||
userStore: di.inject(userStoreInjectable),
|
||||
@@ -20,8 +22,6 @@ const createKubectlInjectable = getInjectable({
|
||||
return (clusterVersion: string) =>
|
||||
new Kubectl(dependencies, clusterVersion);
|
||||
},
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default createKubectlInjectable;
|
||||
+3
-3
@@ -2,15 +2,15 @@
|
||||
* 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 directoryForBinariesInjectable from "../../../common/app-paths/directory-for-binaries/directory-for-binaries.injectable";
|
||||
import path from "path";
|
||||
|
||||
const directoryForKubectlBinariesInjectable = getInjectable({
|
||||
id: "directory-for-kubectl-binaries",
|
||||
|
||||
instantiate: (di) =>
|
||||
path.join(di.inject(directoryForBinariesInjectable), "kubectl"),
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default directoryForKubectlBinariesInjectable;
|
||||
@@ -2,12 +2,12 @@
|
||||
* 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 { computed } from "mobx";
|
||||
import mainExtensionsInjectable from "../../extensions/main-extensions.injectable";
|
||||
|
||||
const electronMenuItemsInjectable = getInjectable({
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
id: "electron-menu-items",
|
||||
|
||||
instantiate: (di) => {
|
||||
const extensions = di.inject(mainExtensionsInjectable);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { ConfigurableDependencyInjectionContainer } from "@ogre-tools/injectable";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import { LensMainExtension } from "../../extensions/lens-main-extension";
|
||||
import electronMenuItemsInjectable from "./electron-menu-items.injectable";
|
||||
import type { IComputedValue } from "mobx";
|
||||
@@ -12,7 +12,7 @@ import { getDiForUnitTesting } from "../getDiForUnitTesting";
|
||||
import mainExtensionsInjectable from "../../extensions/main-extensions.injectable";
|
||||
|
||||
describe("electron-menu-items", () => {
|
||||
let di: ConfigurableDependencyInjectionContainer;
|
||||
let di: DiContainer;
|
||||
let electronMenuItems: IComputedValue<MenuRegistration[]>;
|
||||
let extensionsStub: ObservableMap<string, LensMainExtension>;
|
||||
|
||||
|
||||
+3
-3
@@ -2,19 +2,19 @@
|
||||
* 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 extensionLoaderInjectable from "../../../extensions/extension-loader/extension-loader.injectable";
|
||||
import { LensProtocolRouterMain } from "./lens-protocol-router-main";
|
||||
import extensionsStoreInjectable from "../../../extensions/extensions-store/extensions-store.injectable";
|
||||
|
||||
const lensProtocolRouterMainInjectable = getInjectable({
|
||||
id: "lens-protocol-router-main",
|
||||
|
||||
instantiate: (di) =>
|
||||
new LensProtocolRouterMain({
|
||||
extensionLoader: di.inject(extensionLoaderInjectable),
|
||||
extensionsStore: di.inject(extensionsStoreInjectable),
|
||||
}),
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default lensProtocolRouterMainInjectable;
|
||||
@@ -2,19 +2,19 @@
|
||||
* 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 { shellApiRequest } from "./shell-api-request";
|
||||
import createShellSessionInjectable from "../../shell-session/create-shell-session.injectable";
|
||||
import shellRequestAuthenticatorInjectable
|
||||
from "./shell-request-authenticator/shell-request-authenticator.injectable";
|
||||
|
||||
const shellApiRequestInjectable = getInjectable({
|
||||
id: "shell-api-request",
|
||||
|
||||
instantiate: (di) => shellApiRequest({
|
||||
createShellSession: di.inject(createShellSessionInjectable),
|
||||
authenticateRequest: di.inject(shellRequestAuthenticatorInjectable).authenticate,
|
||||
}),
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default shellApiRequestInjectable;
|
||||
+3
-3
@@ -2,10 +2,12 @@
|
||||
* 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 { ShellRequestAuthenticator } from "./shell-request-authenticator";
|
||||
|
||||
const shellRequestAuthenticatorInjectable = getInjectable({
|
||||
id: "shell-request-authenticator",
|
||||
|
||||
instantiate: () => {
|
||||
const authenticator = new ShellRequestAuthenticator();
|
||||
|
||||
@@ -13,8 +15,6 @@ const shellRequestAuthenticatorInjectable = getInjectable({
|
||||
|
||||
return authenticator;
|
||||
},
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default shellRequestAuthenticatorInjectable;
|
||||
@@ -2,17 +2,17 @@
|
||||
* 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 { Router } from "../router";
|
||||
import routePortForwardInjectable
|
||||
from "../routes/port-forward/route-port-forward/route-port-forward.injectable";
|
||||
|
||||
const routerInjectable = getInjectable({
|
||||
id: "router",
|
||||
|
||||
instantiate: (di) => new Router({
|
||||
routePortForward: di.inject(routePortForwardInjectable),
|
||||
}),
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default routerInjectable;
|
||||
@@ -2,11 +2,13 @@
|
||||
* 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 { PortForward, PortForwardArgs } from "./port-forward";
|
||||
import bundledKubectlInjectable from "../../kubectl/bundled-kubectl.injectable";
|
||||
|
||||
const createPortForwardInjectable = getInjectable({
|
||||
id: "create-port-forward",
|
||||
|
||||
instantiate: (di) => {
|
||||
const bundledKubectl = di.inject(bundledKubectlInjectable);
|
||||
|
||||
@@ -17,8 +19,6 @@ const createPortForwardInjectable = getInjectable({
|
||||
return (pathToKubeConfig: string, args: PortForwardArgs) =>
|
||||
new PortForward(dependencies, pathToKubeConfig, args);
|
||||
},
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default createPortForwardInjectable;
|
||||
@@ -3,15 +3,15 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { routePortForward } from "./route-port-forward";
|
||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import createPortForwardInjectable from "../create-port-forward.injectable";
|
||||
|
||||
const routePortForwardInjectable = getInjectable({
|
||||
id: "route-port-forward",
|
||||
|
||||
instantiate: (di) => routePortForward({
|
||||
createPortForward: di.inject(createPortForwardInjectable),
|
||||
}),
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default routePortForwardInjectable;
|
||||
@@ -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 localShellSessionInjectable from "./local-shell-session/local-shell-session.injectable";
|
||||
@@ -16,14 +16,14 @@ interface Args {
|
||||
}
|
||||
|
||||
const createShellSessionInjectable = getInjectable({
|
||||
id: "create-shell-session",
|
||||
|
||||
instantiate:
|
||||
(di) =>
|
||||
({ nodeName, ...rest }: Args) =>
|
||||
!nodeName
|
||||
? di.inject(localShellSessionInjectable, rest)
|
||||
: di.inject(nodeShellSessionInjectable, { nodeName, ...rest }),
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default createShellSessionInjectable;
|
||||
@@ -16,6 +16,8 @@ interface InstantiationParameter {
|
||||
}
|
||||
|
||||
const localShellSessionInjectable = getInjectable({
|
||||
id: "local-shell-session",
|
||||
|
||||
instantiate: (di, { cluster, tabId, webSocket }: InstantiationParameter) => {
|
||||
const createKubectl = di.inject(createKubectlInjectable);
|
||||
const localShellEnvModify = di.inject(terminalShellEnvModifiersInjectable);
|
||||
|
||||
@@ -16,6 +16,8 @@ interface InstantiationParameter {
|
||||
}
|
||||
|
||||
const nodeShellSessionInjectable = getInjectable({
|
||||
id: "node-shell-session",
|
||||
|
||||
instantiate: (di, { cluster, tabId, webSocket, nodeName }: InstantiationParameter) => {
|
||||
const createKubectl = di.inject(createKubectlInjectable);
|
||||
|
||||
|
||||
@@ -6,14 +6,16 @@
|
||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||
import mainExtensionsInjectable from "../../../extensions/main-extensions.injectable";
|
||||
import { terminalShellEnvModify } from "./terminal-shell-env-modifiers";
|
||||
|
||||
|
||||
const terminalShellEnvModifyInjectable = getInjectable({
|
||||
id: "terminal-shell-env-modify",
|
||||
|
||||
instantiate: (di) =>
|
||||
terminalShellEnvModify({
|
||||
extensions: di.inject(mainExtensionsInjectable),
|
||||
}),
|
||||
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
|
||||
export default terminalShellEnvModifyInjectable;
|
||||
@@ -2,12 +2,12 @@
|
||||
* 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 { computed } from "mobx";
|
||||
import mainExtensionsInjectable from "../../extensions/main-extensions.injectable";
|
||||
|
||||
const trayItemsInjectable = getInjectable({
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
id: "tray-items",
|
||||
|
||||
instantiate: (di) => {
|
||||
const extensions = di.inject(mainExtensionsInjectable);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { ConfigurableDependencyInjectionContainer } from "@ogre-tools/injectable";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import { LensMainExtension } from "../../extensions/lens-main-extension";
|
||||
import trayItemsInjectable from "./tray-menu-items.injectable";
|
||||
import type { IComputedValue } from "mobx";
|
||||
@@ -12,7 +12,7 @@ import mainExtensionsInjectable from "../../extensions/main-extensions.injectabl
|
||||
import type { TrayMenuRegistration } from "./tray-menu-registration";
|
||||
|
||||
describe("tray-menu-items", () => {
|
||||
let di: ConfigurableDependencyInjectionContainer;
|
||||
let di: DiContainer;
|
||||
let trayMenuItems: IComputedValue<TrayMenuRegistration[]>;
|
||||
let extensionsStub: ObservableMap<string, LensMainExtension>;
|
||||
|
||||
|
||||
Reference in new issue
Block a user