From 2d4d8e35c96fd5d43c7717f74a01dbfb4b50d406 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Tue, 1 Mar 2022 12:45:55 -0500 Subject: [PATCH] Fix helm downloading on windows Signed-off-by: Sebastian Malton --- build/download_binaries.ts | 69 ++++++++++++++++++++++++-------------- package.json | 6 ++-- src/common/vars.ts | 15 ++++----- 3 files changed, 54 insertions(+), 36 deletions(-) diff --git a/build/download_binaries.ts b/build/download_binaries.ts index ce1ddaf8d0..c59ef2d08b 100644 --- a/build/download_binaries.ts +++ b/build/download_binaries.ts @@ -154,11 +154,6 @@ class HelmDownloader extends BinaryDownloader { type SupportedPlatform = "darwin" | "linux" | "windows"; -interface SupportedArch { - downloadArch: string; - fileArch: string; -} - async function main() { const multiBar = new MultiBar({ align: "left", @@ -169,44 +164,68 @@ async function main() { format: "[{bar}] {percentage}% | {downloadArch} {binaryName}", }); const baseDir = path.join(__dirname, "..", "binaries", "client"); - const supportedArchitectures: SupportedArch[] = [ - { + const downloaders: BinaryDownloader[] = [ + new LensK8sProxyDownloader({ + version: packageInfo.config.k8sProxyVersion, + platform: normalizedPlatform, downloadArch: "amd64", fileArch: "x64", - }, - normalizedPlatform === "windows" - ? { - downloadArch: "386", - fileArch: "ia32", - } - : { - downloadArch: "arm64", - fileArch: "arm64", - }, + baseDir, + }, multiBar), + new KubectlDownloader({ + version: packageInfo.config.bundledKubectlVersion, + platform: normalizedPlatform, + downloadArch: "amd64", + fileArch: "x64", + baseDir, + }, multiBar), + new HelmDownloader({ + version: packageInfo.config.bundledHelmVersion, + platform: normalizedPlatform, + downloadArch: "amd64", + fileArch: "x64", + baseDir, + }, multiBar), ]; - const downloaders: BinaryDownloader[] = []; - for (const { downloadArch, fileArch } of supportedArchitectures) { + if (normalizedPlatform === "windows") { downloaders.push( new LensK8sProxyDownloader({ version: packageInfo.config.k8sProxyVersion, platform: normalizedPlatform, - downloadArch, - fileArch, + downloadArch: "386", + fileArch: "ia32", baseDir, }, multiBar), new KubectlDownloader({ version: packageInfo.config.bundledKubectlVersion, platform: normalizedPlatform, - downloadArch, - fileArch, + downloadArch: "386", + fileArch: "ia32", + baseDir, + }, multiBar), + ); + } else { + downloaders.push( + new LensK8sProxyDownloader({ + version: packageInfo.config.k8sProxyVersion, + platform: normalizedPlatform, + downloadArch: "arm64", + fileArch: "arm64", + baseDir, + }, multiBar), + new KubectlDownloader({ + version: packageInfo.config.bundledKubectlVersion, + platform: normalizedPlatform, + downloadArch: "arm64", + fileArch: "arm64", baseDir, }, multiBar), new HelmDownloader({ version: packageInfo.config.bundledHelmVersion, platform: normalizedPlatform, - downloadArch, - fileArch, + downloadArch: "arm64", + fileArch: "arm64", baseDir, }, multiBar), ); diff --git a/package.json b/package.json index 86cb5f830f..32ec958a07 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ }, { "from": "binaries/client/linux/${arch}/helm", - "to": "./${arch}/helm" + "to": "./helm" } ] }, @@ -158,7 +158,7 @@ }, { "from": "binaries/client/darwin/${arch}/helm", - "to": "./${arch}/helm" + "to": "./helm" } ] }, @@ -185,7 +185,7 @@ }, { "from": "binaries/client/windows/x64/helm.exe", - "to": "./x64/helm.exe" + "to": "./helm.exe" } ] }, diff --git a/src/common/vars.ts b/src/common/vars.ts index a6ea2653df..df55e6d69d 100644 --- a/src/common/vars.ts +++ b/src/common/vars.ts @@ -66,17 +66,16 @@ export function getBinaryName(name: string, { forPlatform = normalizedPlatform } return name; } -export const baseBinariesDir = onceCell(() => ( - path.join( - isProduction - ? process.resourcesPath - : path.join(process.cwd(), "binaries", "client", normalizedPlatform), - normalizedArch, - ) +export const resourcesDir = onceCell(() => ( + isProduction + ? process.resourcesPath + : path.join(process.cwd(), "binaries", "client", normalizedPlatform) )); +export const baseBinariesDir = onceCell(() => path.join(resourcesDir.get(), normalizedArch)); + export const helmBinaryName = getBinaryName("helm"); -export const helmBinaryPath = onceCell(() => path.join(baseBinariesDir.get(), helmBinaryName)); +export const helmBinaryPath = onceCell(() => path.join(resourcesDir.get(), helmBinaryName)); export const kubectlBinaryName = getBinaryName("kubectl"); export const kubectlBinaryPath = onceCell(() => path.join(baseBinariesDir.get(), kubectlBinaryName));