1
0
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:
Sebastian Malton 2022-11-25 09:19:35 -05:00
parent 285c9f2b92
commit eb5d3b1e1c
6 changed files with 32 additions and 34 deletions

View File

@ -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);

View 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;

View File

@ -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;

View File

@ -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;

View File

@ -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",

View File

@ -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;