diff --git a/src/common/utils/get-binary-name.injectable.ts b/src/common/utils/binary-name.injectable.ts similarity index 96% rename from src/common/utils/get-binary-name.injectable.ts rename to src/common/utils/binary-name.injectable.ts index 39b28b0e3e..d240b3aae0 100644 --- a/src/common/utils/get-binary-name.injectable.ts +++ b/src/common/utils/binary-name.injectable.ts @@ -6,7 +6,7 @@ import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import normalizedPlatformInjectable from "../vars/normalized-platform.injectable"; const binaryNameInjectable = getInjectable({ - id: "get-binary-name", + id: "binary-name", instantiate: (di, binaryName) => { const normalizedPlatform = di.inject(normalizedPlatformInjectable); diff --git a/src/common/utils/bundled-binary-path.injectable.ts b/src/common/utils/bundled-binary-path.injectable.ts new file mode 100644 index 0000000000..42ecbca0d9 --- /dev/null +++ b/src/common/utils/bundled-binary-path.injectable.ts @@ -0,0 +1,24 @@ +/** + * 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 joinPathsInjectable from "../path/join-paths.injectable"; +import baseBundledBinariesDirectoryInjectable from "../vars/base-bundled-binaries-dir.injectable"; +import binaryNameInjectable from "./binary-name.injectable"; + +const bundledBinaryPathInjectable = getInjectable({ + id: "bundled-binary-path", + instantiate: (di, name) => { + const joinPaths = di.inject(joinPathsInjectable); + const binaryName = di.inject(binaryNameInjectable, name); + const baseBundledBinariesDirectory = di.inject(baseBundledBinariesDirectoryInjectable); + + return joinPaths(baseBundledBinariesDirectory, binaryName); + }, + lifecycle: lifecycleEnum.keyedSingleton({ + getInstanceKey: (di, binaryName: string) => binaryName, + }), +}); + +export default bundledBinaryPathInjectable; diff --git a/src/main/helm/helm-binary-path.injectable.ts b/src/main/helm/helm-binary-path.injectable.ts index 8197944edc..19913dfcca 100644 --- a/src/main/helm/helm-binary-path.injectable.ts +++ b/src/main/helm/helm-binary-path.injectable.ts @@ -3,20 +3,11 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import baseBundledBinariesDirectoryInjectable from "../../common/vars/base-bundled-binaries-dir.injectable"; -import joinPathsInjectable from "../../common/path/join-paths.injectable"; -import binaryNameInjectable from "../../common/utils/get-binary-name.injectable"; +import bundledBinaryPathInjectable from "../../common/utils/bundled-binary-path.injectable"; const helmBinaryPathInjectable = getInjectable({ id: "helm-binary-path", - - instantiate: (di) => { - const joinPaths = di.inject(joinPathsInjectable); - const binaryName = di.inject(binaryNameInjectable, "helm"); - const baseBundledBinariesDirectory = di.inject(baseBundledBinariesDirectoryInjectable); - - return joinPaths(baseBundledBinariesDirectory, binaryName); - }, + instantiate: (di) => di.inject(bundledBinaryPathInjectable, "helm"), }); export default helmBinaryPathInjectable; diff --git a/src/main/kube-auth-proxy/lens-k8s-proxy-path.injectable.ts b/src/main/kube-auth-proxy/lens-k8s-proxy-path.injectable.ts index b2ac74de39..cd13bdcf5e 100644 --- a/src/main/kube-auth-proxy/lens-k8s-proxy-path.injectable.ts +++ b/src/main/kube-auth-proxy/lens-k8s-proxy-path.injectable.ts @@ -3,19 +3,11 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import joinPathsInjectable from "../../common/path/join-paths.injectable"; -import binaryNameInjectable from "../../common/utils/get-binary-name.injectable"; -import baseBundledBinariesDirectoryInjectable from "../../common/vars/base-bundled-binaries-dir.injectable"; +import bundledBinaryPathInjectable from "../../common/utils/bundled-binary-path.injectable"; const lensK8sProxyPathInjectable = getInjectable({ id: "lens-k8s-proxy-path", - instantiate: (di) => { - const joinPaths = di.inject(joinPathsInjectable); - const binaryName = di.inject(binaryNameInjectable, "lens-k8s-proxy"); - const baseBundledBinariesDirectory = di.inject(baseBundledBinariesDirectoryInjectable); - - return joinPaths(baseBundledBinariesDirectory, binaryName); - }, + instantiate: (di) => di.inject(bundledBinaryPathInjectable, "lens-k8s-proxy"), }); export default lensK8sProxyPathInjectable; diff --git a/src/main/kubectl/binary-name.injectable.ts b/src/main/kubectl/binary-name.injectable.ts index 5cc2f19f0c..f21cabd76e 100644 --- a/src/main/kubectl/binary-name.injectable.ts +++ b/src/main/kubectl/binary-name.injectable.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import binaryNameInjectable from "../../common/utils/get-binary-name.injectable"; +import binaryNameInjectable from "../../common/utils/binary-name.injectable"; const kubectlBinaryNameInjectable = getInjectable({ id: "kubectl-binary-name", diff --git a/src/main/kubectl/bundled-binary-path.injectable.ts b/src/main/kubectl/bundled-binary-path.injectable.ts index f3321f7776..bad89af5f6 100644 --- a/src/main/kubectl/bundled-binary-path.injectable.ts +++ b/src/main/kubectl/bundled-binary-path.injectable.ts @@ -3,20 +3,11 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import joinPathsInjectable from "../../common/path/join-paths.injectable"; -import baseBundledBinariesDirectoryInjectable from "../../common/vars/base-bundled-binaries-dir.injectable"; -import kubectlBinaryNameInjectable from "./binary-name.injectable"; +import bundledBinaryPathInjectable from "../../common/utils/bundled-binary-path.injectable"; const bundledKubectlBinaryPathInjectable = getInjectable({ id: "bundled-kubectl-binary-path", - instantiate: (di) => { - const joinPaths = di.inject(joinPathsInjectable); - - return joinPaths( - di.inject(baseBundledBinariesDirectoryInjectable), - di.inject(kubectlBinaryNameInjectable), - ); - }, + instantiate: (di) => di.inject(bundledBinaryPathInjectable, "kubectl"), }); export default bundledKubectlBinaryPathInjectable;