1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Add new injectable version of binaryName

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-11-16 11:52:16 -05:00
parent 0c992489bc
commit 7cbf59dc86
4 changed files with 50 additions and 14 deletions

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 normalizedPlatformInjectable from "../vars/normalized-platform.injectable";
const binaryNameInjectable = getInjectable({
id: "get-binary-name",
instantiate: (di, binaryName) => {
const normalizedPlatform = di.inject(normalizedPlatformInjectable);
if (normalizedPlatform === "windows") {
return `${binaryName}.exe`;
}
return binaryName;
},
lifecycle: lifecycleEnum.keyedSingleton({
getInstanceKey: (di, binaryName: string) => binaryName,
}),
});
export default binaryNameInjectable;

View File

@ -3,22 +3,19 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { getBinaryName } from "../../common/vars";
import normalizedPlatformInjectable from "../../common/vars/normalized-platform.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";
const helmBinaryPathInjectable = getInjectable({
id: "helm-binary-path",
instantiate: (di) => {
const joinPaths = di.inject(joinPathsInjectable);
const normalizedPlatform = di.inject(normalizedPlatformInjectable);
const binaryName = di.inject(binaryNameInjectable, "helm");
const baseBundledBinariesDirectory = di.inject(baseBundledBinariesDirectoryInjectable);
const helmBinaryName = getBinaryName("helm", { forPlatform: normalizedPlatform });
return joinPaths(baseBundledBinariesDirectory, helmBinaryName);
return joinPaths(baseBundledBinariesDirectory, binaryName);
},
});

View File

@ -0,0 +1,21 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* 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";
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);
},
});
export default lensK8sProxyPathInjectable;

View File

@ -3,17 +3,11 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import normalizedPlatformInjectable from "../../common/vars/normalized-platform.injectable";
import binaryNameInjectable from "../../common/utils/get-binary-name.injectable";
const kubectlBinaryNameInjectable = getInjectable({
id: "kubectl-binary-name",
instantiate: (di) => {
const platform = di.inject(normalizedPlatformInjectable);
return platform === "windows"
? "kubectl.exe"
: "kubectl";
},
instantiate: (di) => di.inject(binaryNameInjectable, "kubectl"),
});
export default kubectlBinaryNameInjectable;