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:
parent
0c992489bc
commit
7cbf59dc86
24
src/common/utils/get-binary-name.injectable.ts
Normal file
24
src/common/utils/get-binary-name.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 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;
|
||||||
@ -3,22 +3,19 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
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 baseBundledBinariesDirectoryInjectable from "../../common/vars/base-bundled-binaries-dir.injectable";
|
||||||
import joinPathsInjectable from "../../common/path/join-paths.injectable";
|
import joinPathsInjectable from "../../common/path/join-paths.injectable";
|
||||||
|
import binaryNameInjectable from "../../common/utils/get-binary-name.injectable";
|
||||||
|
|
||||||
const helmBinaryPathInjectable = getInjectable({
|
const helmBinaryPathInjectable = getInjectable({
|
||||||
id: "helm-binary-path",
|
id: "helm-binary-path",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const joinPaths = di.inject(joinPathsInjectable);
|
const joinPaths = di.inject(joinPathsInjectable);
|
||||||
const normalizedPlatform = di.inject(normalizedPlatformInjectable);
|
const binaryName = di.inject(binaryNameInjectable, "helm");
|
||||||
const baseBundledBinariesDirectory = di.inject(baseBundledBinariesDirectoryInjectable);
|
const baseBundledBinariesDirectory = di.inject(baseBundledBinariesDirectoryInjectable);
|
||||||
|
|
||||||
const helmBinaryName = getBinaryName("helm", { forPlatform: normalizedPlatform });
|
return joinPaths(baseBundledBinariesDirectory, binaryName);
|
||||||
|
|
||||||
return joinPaths(baseBundledBinariesDirectory, helmBinaryName);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
21
src/main/kube-auth-proxy/lens-k8s-proxy-path.injectable.ts
Normal file
21
src/main/kube-auth-proxy/lens-k8s-proxy-path.injectable.ts
Normal 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;
|
||||||
@ -3,17 +3,11 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
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({
|
const kubectlBinaryNameInjectable = getInjectable({
|
||||||
id: "kubectl-binary-name",
|
id: "kubectl-binary-name",
|
||||||
instantiate: (di) => {
|
instantiate: (di) => di.inject(binaryNameInjectable, "kubectl"),
|
||||||
const platform = di.inject(normalizedPlatformInjectable);
|
|
||||||
|
|
||||||
return platform === "windows"
|
|
||||||
? "kubectl.exe"
|
|
||||||
: "kubectl";
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default kubectlBinaryNameInjectable;
|
export default kubectlBinaryNameInjectable;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user