mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Cleanup creating binary names and paths
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
285c9f2b92
commit
eb5d3b1e1c
@ -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);
|
||||
|
||||
24
src/common/utils/bundled-binary-path.injectable.ts
Normal file
24
src/common/utils/bundled-binary-path.injectable.ts
Normal file
@ -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;
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user