mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove duplication how to acquire binary path for helm
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
506b61234f
commit
bcfa57d5b0
@ -3,16 +3,22 @@
|
|||||||
* 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 path from "path";
|
|
||||||
import normalizedPlatformArchitecture from "./normalized-platform-architecture.injectable";
|
|
||||||
import bundledResourcesDirectoryInjectable from "./bundled-resources-dir.injectable";
|
import bundledResourcesDirectoryInjectable from "./bundled-resources-dir.injectable";
|
||||||
|
import getAbsolutePathInjectable from "../path/get-absolute-path.injectable";
|
||||||
|
import normalizedPlatformArchitectureInjectable from "./normalized-platform-architecture.injectable";
|
||||||
|
|
||||||
const baseBundeledBinariesDirectoryInjectable = getInjectable({
|
const baseBundledBinariesDirectoryInjectable = getInjectable({
|
||||||
id: "base-bundeled-binaries-directory",
|
id: "base-bundled-binaries-directory",
|
||||||
instantiate: (di) => path.join(
|
instantiate: (di) => {
|
||||||
di.inject(bundledResourcesDirectoryInjectable),
|
const bundledResourcesDirectory = di.inject(bundledResourcesDirectoryInjectable);
|
||||||
di.inject(normalizedPlatformArchitecture),
|
const normalizedPlatformArchitecture = di.inject(normalizedPlatformArchitectureInjectable);
|
||||||
),
|
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
|
||||||
|
|
||||||
|
return getAbsolutePath(
|
||||||
|
bundledResourcesDirectory,
|
||||||
|
normalizedPlatformArchitecture,
|
||||||
|
);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default baseBundeledBinariesDirectoryInjectable;
|
export default baseBundledBinariesDirectoryInjectable;
|
||||||
|
|||||||
@ -3,19 +3,22 @@
|
|||||||
* 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 path from "path";
|
|
||||||
import isProductionInjectable from "./is-production.injectable";
|
import isProductionInjectable from "./is-production.injectable";
|
||||||
import normalizedPlatformInjectable from "./normalized-platform.injectable";
|
import normalizedPlatformInjectable from "./normalized-platform.injectable";
|
||||||
|
import getAbsolutePathInjectable from "../path/get-absolute-path.injectable";
|
||||||
|
import lensResourcesDirInjectable from "./lens-resources-dir.injectable";
|
||||||
|
|
||||||
const bundledResourcesDirectoryInjectable = getInjectable({
|
const bundledResourcesDirectoryInjectable = getInjectable({
|
||||||
id: "bundled-resources-directory",
|
id: "bundled-resources-directory",
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const isProduction = di.inject(isProductionInjectable);
|
const isProduction = di.inject(isProductionInjectable);
|
||||||
const normalizedPlatform = di.inject(normalizedPlatformInjectable);
|
const normalizedPlatform = di.inject(normalizedPlatformInjectable);
|
||||||
|
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
|
||||||
|
const lensResourcesDir = di.inject(lensResourcesDirInjectable);
|
||||||
|
|
||||||
return isProduction
|
return isProduction
|
||||||
? process.resourcesPath
|
? lensResourcesDir
|
||||||
: path.join(process.cwd(), "binaries", "client", normalizedPlatform);
|
: getAbsolutePath(lensResourcesDir, "binaries", "client", normalizedPlatform);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -76,7 +76,7 @@ import quitAndInstallUpdateInjectable from "./electron-app/features/quit-and-ins
|
|||||||
import electronUpdaterIsActiveInjectable from "./electron-app/features/electron-updater-is-active.injectable";
|
import electronUpdaterIsActiveInjectable from "./electron-app/features/electron-updater-is-active.injectable";
|
||||||
import publishIsConfiguredInjectable from "./application-update/publish-is-configured.injectable";
|
import publishIsConfiguredInjectable from "./application-update/publish-is-configured.injectable";
|
||||||
import checkForPlatformUpdatesInjectable from "./application-update/check-for-platform-updates/check-for-platform-updates.injectable";
|
import checkForPlatformUpdatesInjectable from "./application-update/check-for-platform-updates/check-for-platform-updates.injectable";
|
||||||
import baseBundeledBinariesDirectoryInjectable from "../common/vars/base-bundled-binaries-dir.injectable";
|
import baseBundledBinariesDirectoryInjectable from "../common/vars/base-bundled-binaries-dir.injectable";
|
||||||
import setUpdateOnQuitInjectable from "./electron-app/features/set-update-on-quit.injectable";
|
import setUpdateOnQuitInjectable from "./electron-app/features/set-update-on-quit.injectable";
|
||||||
import downloadPlatformUpdateInjectable from "./application-update/download-platform-update/download-platform-update.injectable";
|
import downloadPlatformUpdateInjectable from "./application-update/download-platform-update/download-platform-update.injectable";
|
||||||
import startCatalogSyncInjectable from "./catalog-sync-to-renderer/start-catalog-sync.injectable";
|
import startCatalogSyncInjectable from "./catalog-sync-to-renderer/start-catalog-sync.injectable";
|
||||||
@ -172,7 +172,7 @@ export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {})
|
|||||||
di.override(broadcastMessageInjectable, () => (channel) => {
|
di.override(broadcastMessageInjectable, () => (channel) => {
|
||||||
throw new Error(`Tried to broadcast message to channel "${channel}" over IPC without explicit override.`);
|
throw new Error(`Tried to broadcast message to channel "${channel}" over IPC without explicit override.`);
|
||||||
});
|
});
|
||||||
di.override(baseBundeledBinariesDirectoryInjectable, () => "some-bin-directory");
|
di.override(baseBundledBinariesDirectoryInjectable, () => "some-bin-directory");
|
||||||
di.override(spawnInjectable, () => () => {
|
di.override(spawnInjectable, () => () => {
|
||||||
return {
|
return {
|
||||||
stderr: { on: jest.fn(), removeAllListeners: jest.fn() },
|
stderr: { on: jest.fn(), removeAllListeners: jest.fn() },
|
||||||
|
|||||||
@ -5,30 +5,20 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { getBinaryName } from "../../common/vars";
|
import { getBinaryName } from "../../common/vars";
|
||||||
import getAbsolutePathInjectable from "../../common/path/get-absolute-path.injectable";
|
import getAbsolutePathInjectable from "../../common/path/get-absolute-path.injectable";
|
||||||
import lensResourcesDirInjectable from "../../common/vars/lens-resources-dir.injectable";
|
|
||||||
import normalizedPlatformInjectable from "../../common/vars/normalized-platform.injectable";
|
import normalizedPlatformInjectable from "../../common/vars/normalized-platform.injectable";
|
||||||
import isProductionInjectable from "../../common/vars/is-production.injectable";
|
import baseBundledBinariesDirectoryInjectable from "../../common/vars/base-bundled-binaries-dir.injectable";
|
||||||
import normalizedPlatformArchitectureInjectable from "../../common/vars/normalized-platform-architecture.injectable";
|
|
||||||
|
|
||||||
const helmBinaryPathInjectable = getInjectable({
|
const helmBinaryPathInjectable = getInjectable({
|
||||||
id: "helm-binary-path",
|
id: "helm-binary-path",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
|
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
|
||||||
const lensResourcesDir = di.inject(lensResourcesDirInjectable);
|
|
||||||
const normalizedPlatform = di.inject(normalizedPlatformInjectable);
|
const normalizedPlatform = di.inject(normalizedPlatformInjectable);
|
||||||
const normalizedPlatformArchitecture = di.inject(normalizedPlatformArchitectureInjectable);
|
const baseBundledBinariesDirectory = di.inject(baseBundledBinariesDirectoryInjectable);
|
||||||
const isProduction = di.inject(isProductionInjectable);
|
|
||||||
|
|
||||||
const resourcesDir = isProduction
|
|
||||||
? lensResourcesDir
|
|
||||||
: getAbsolutePath(lensResourcesDir, "binaries", "client", normalizedPlatform);
|
|
||||||
|
|
||||||
const baseBinariesDir = getAbsolutePath(resourcesDir, normalizedPlatformArchitecture);
|
|
||||||
|
|
||||||
const helmBinaryName = getBinaryName("helm", { forPlatform: normalizedPlatform });
|
const helmBinaryName = getBinaryName("helm", { forPlatform: normalizedPlatform });
|
||||||
|
|
||||||
return getAbsolutePath(baseBinariesDir, helmBinaryName);
|
return getAbsolutePath(baseBundledBinariesDirectory, helmBinaryName);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import { getBinaryName } from "../../common/vars";
|
|||||||
import spawnInjectable from "../child-process/spawn.injectable";
|
import spawnInjectable from "../child-process/spawn.injectable";
|
||||||
import { getKubeAuthProxyCertificate } from "./get-kube-auth-proxy-certificate";
|
import { getKubeAuthProxyCertificate } from "./get-kube-auth-proxy-certificate";
|
||||||
import loggerInjectable from "../../common/logger.injectable";
|
import loggerInjectable from "../../common/logger.injectable";
|
||||||
import baseBundeledBinariesDirectoryInjectable from "../../common/vars/base-bundled-binaries-dir.injectable";
|
import baseBundledBinariesDirectoryInjectable from "../../common/vars/base-bundled-binaries-dir.injectable";
|
||||||
|
|
||||||
export type CreateKubeAuthProxy = (cluster: Cluster, environmentVariables: NodeJS.ProcessEnv) => KubeAuthProxy;
|
export type CreateKubeAuthProxy = (cluster: Cluster, environmentVariables: NodeJS.ProcessEnv) => KubeAuthProxy;
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ const createKubeAuthProxyInjectable = getInjectable({
|
|||||||
return (cluster: Cluster, environmentVariables: NodeJS.ProcessEnv) => {
|
return (cluster: Cluster, environmentVariables: NodeJS.ProcessEnv) => {
|
||||||
const clusterUrl = new URL(cluster.apiUrl);
|
const clusterUrl = new URL(cluster.apiUrl);
|
||||||
const dependencies: KubeAuthProxyDependencies = {
|
const dependencies: KubeAuthProxyDependencies = {
|
||||||
proxyBinPath: path.join(di.inject(baseBundeledBinariesDirectoryInjectable), binaryName),
|
proxyBinPath: path.join(di.inject(baseBundledBinariesDirectoryInjectable), binaryName),
|
||||||
proxyCert: getKubeAuthProxyCertificate(clusterUrl.hostname, selfsigned.generate),
|
proxyCert: getKubeAuthProxyCertificate(clusterUrl.hostname, selfsigned.generate),
|
||||||
spawn: di.inject(spawnInjectable),
|
spawn: di.inject(spawnInjectable),
|
||||||
logger: di.inject(loggerInjectable),
|
logger: di.inject(loggerInjectable),
|
||||||
|
|||||||
@ -4,13 +4,13 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import baseBundeledBinariesDirectoryInjectable from "../../common/vars/base-bundled-binaries-dir.injectable";
|
import baseBundledBinariesDirectoryInjectable from "../../common/vars/base-bundled-binaries-dir.injectable";
|
||||||
import kubectlBinaryNameInjectable from "./binary-name.injectable";
|
import kubectlBinaryNameInjectable from "./binary-name.injectable";
|
||||||
|
|
||||||
const bundledKubectlBinaryPathInjectable = getInjectable({
|
const bundledKubectlBinaryPathInjectable = getInjectable({
|
||||||
id: "bundled-kubectl-binary-path",
|
id: "bundled-kubectl-binary-path",
|
||||||
instantiate: (di) => path.join(
|
instantiate: (di) => path.join(
|
||||||
di.inject(baseBundeledBinariesDirectoryInjectable),
|
di.inject(baseBundledBinariesDirectoryInjectable),
|
||||||
di.inject(kubectlBinaryNameInjectable),
|
di.inject(kubectlBinaryNameInjectable),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import kubectlDownloadingNormalizedArchInjectable from "./normalized-arch.inject
|
|||||||
import normalizedPlatformInjectable from "../../common/vars/normalized-platform.injectable";
|
import normalizedPlatformInjectable from "../../common/vars/normalized-platform.injectable";
|
||||||
import kubectlBinaryNameInjectable from "./binary-name.injectable";
|
import kubectlBinaryNameInjectable from "./binary-name.injectable";
|
||||||
import bundledKubectlBinaryPathInjectable from "./bundled-binary-path.injectable";
|
import bundledKubectlBinaryPathInjectable from "./bundled-binary-path.injectable";
|
||||||
import baseBundeledBinariesDirectoryInjectable from "../../common/vars/base-bundled-binaries-dir.injectable";
|
import baseBundledBinariesDirectoryInjectable from "../../common/vars/base-bundled-binaries-dir.injectable";
|
||||||
|
|
||||||
const createKubectlInjectable = getInjectable({
|
const createKubectlInjectable = getInjectable({
|
||||||
id: "create-kubectl",
|
id: "create-kubectl",
|
||||||
@ -24,7 +24,7 @@ const createKubectlInjectable = getInjectable({
|
|||||||
normalizedDownloadPlatform: di.inject(normalizedPlatformInjectable),
|
normalizedDownloadPlatform: di.inject(normalizedPlatformInjectable),
|
||||||
kubectlBinaryName: di.inject(kubectlBinaryNameInjectable),
|
kubectlBinaryName: di.inject(kubectlBinaryNameInjectable),
|
||||||
bundledKubectlBinaryPath: di.inject(bundledKubectlBinaryPathInjectable),
|
bundledKubectlBinaryPath: di.inject(bundledKubectlBinaryPathInjectable),
|
||||||
baseBundeledBinariesDirectory: di.inject(baseBundeledBinariesDirectoryInjectable),
|
baseBundeledBinariesDirectory: di.inject(baseBundledBinariesDirectoryInjectable),
|
||||||
};
|
};
|
||||||
|
|
||||||
return (clusterVersion: string) => new Kubectl(dependencies, clusterVersion);
|
return (clusterVersion: string) => new Kubectl(dependencies, clusterVersion);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user