mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Don't download binaries for unsupported windows
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
2d4d8e35c9
commit
f00e36b185
@ -18,7 +18,7 @@ import { getBinaryName, normalizedPlatform } from "../src/common/vars";
|
|||||||
|
|
||||||
const pipeline = promisify(_pipeline);
|
const pipeline = promisify(_pipeline);
|
||||||
|
|
||||||
interface DownloadK8sProxyArgs {
|
interface BinaryDownloaderArgs {
|
||||||
readonly version: string;
|
readonly version: string;
|
||||||
readonly platform: SupportedPlatform;
|
readonly platform: SupportedPlatform;
|
||||||
readonly downloadArch: string;
|
readonly downloadArch: string;
|
||||||
@ -36,7 +36,7 @@ abstract class BinaryDownloader {
|
|||||||
return [file];
|
return [file];
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(public readonly args: DownloadK8sProxyArgs, multiBar: MultiBar) {
|
constructor(public readonly args: BinaryDownloaderArgs, multiBar: MultiBar) {
|
||||||
this.bar = multiBar.create(1, 0, args);
|
this.bar = multiBar.create(1, 0, args);
|
||||||
this.target = path.join(args.baseDir, args.platform, args.fileArch, args.binaryName);
|
this.target = path.join(args.baseDir, args.platform, args.fileArch, args.binaryName);
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ abstract class BinaryDownloader {
|
|||||||
class LensK8sProxyDownloader extends BinaryDownloader {
|
class LensK8sProxyDownloader extends BinaryDownloader {
|
||||||
protected readonly url: string;
|
protected readonly url: string;
|
||||||
|
|
||||||
constructor(args: Omit<DownloadK8sProxyArgs, "binaryName">, bar: MultiBar) {
|
constructor(args: Omit<BinaryDownloaderArgs, "binaryName">, bar: MultiBar) {
|
||||||
const binaryName = getBinaryName("lens-k8s-proxy", { forPlatform: args.platform });
|
const binaryName = getBinaryName("lens-k8s-proxy", { forPlatform: args.platform });
|
||||||
|
|
||||||
super({ ...args, binaryName }, bar);
|
super({ ...args, binaryName }, bar);
|
||||||
@ -113,7 +113,7 @@ class LensK8sProxyDownloader extends BinaryDownloader {
|
|||||||
class KubectlDownloader extends BinaryDownloader {
|
class KubectlDownloader extends BinaryDownloader {
|
||||||
protected readonly url: string;
|
protected readonly url: string;
|
||||||
|
|
||||||
constructor(args: Omit<DownloadK8sProxyArgs, "binaryName">, bar: MultiBar) {
|
constructor(args: Omit<BinaryDownloaderArgs, "binaryName">, bar: MultiBar) {
|
||||||
const binaryName = getBinaryName("kubectl", { forPlatform: args.platform });
|
const binaryName = getBinaryName("kubectl", { forPlatform: args.platform });
|
||||||
|
|
||||||
super({ ...args, binaryName }, bar);
|
super({ ...args, binaryName }, bar);
|
||||||
@ -124,7 +124,7 @@ class KubectlDownloader extends BinaryDownloader {
|
|||||||
class HelmDownloader extends BinaryDownloader {
|
class HelmDownloader extends BinaryDownloader {
|
||||||
protected readonly url: string;
|
protected readonly url: string;
|
||||||
|
|
||||||
constructor(args: Omit<DownloadK8sProxyArgs, "binaryName">, bar: MultiBar) {
|
constructor(args: Omit<BinaryDownloaderArgs, "binaryName">, bar: MultiBar) {
|
||||||
const binaryName = getBinaryName("helm", { forPlatform: args.platform });
|
const binaryName = getBinaryName("helm", { forPlatform: args.platform });
|
||||||
|
|
||||||
super({ ...args, binaryName }, bar);
|
super({ ...args, binaryName }, bar);
|
||||||
@ -188,24 +188,7 @@ async function main() {
|
|||||||
}, multiBar),
|
}, multiBar),
|
||||||
];
|
];
|
||||||
|
|
||||||
if (normalizedPlatform === "windows") {
|
if (normalizedPlatform !== "windows") {
|
||||||
downloaders.push(
|
|
||||||
new LensK8sProxyDownloader({
|
|
||||||
version: packageInfo.config.k8sProxyVersion,
|
|
||||||
platform: normalizedPlatform,
|
|
||||||
downloadArch: "386",
|
|
||||||
fileArch: "ia32",
|
|
||||||
baseDir,
|
|
||||||
}, multiBar),
|
|
||||||
new KubectlDownloader({
|
|
||||||
version: packageInfo.config.bundledKubectlVersion,
|
|
||||||
platform: normalizedPlatform,
|
|
||||||
downloadArch: "386",
|
|
||||||
fileArch: "ia32",
|
|
||||||
baseDir,
|
|
||||||
}, multiBar),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
downloaders.push(
|
downloaders.push(
|
||||||
new LensK8sProxyDownloader({
|
new LensK8sProxyDownloader({
|
||||||
version: packageInfo.config.k8sProxyVersion,
|
version: packageInfo.config.k8sProxyVersion,
|
||||||
|
|||||||
@ -9,14 +9,14 @@
|
|||||||
* It then only calls the function on the first call to `get()` and returns the
|
* It then only calls the function on the first call to `get()` and returns the
|
||||||
* same instance/value on every subsequent call.
|
* same instance/value on every subsequent call.
|
||||||
*/
|
*/
|
||||||
export interface OnceCell<T> {
|
export interface LazyInitialized<T> {
|
||||||
get(): T;
|
get(): T;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function to make a `OnceCell<T>`
|
* A function to make a `OnceCell<T>`
|
||||||
*/
|
*/
|
||||||
export function onceCell<T>(builder: () => T): OnceCell<T> {
|
export function lazyInitialized<T>(builder: () => T): LazyInitialized<T> {
|
||||||
let value: T | undefined;
|
let value: T | undefined;
|
||||||
let called = false;
|
let called = false;
|
||||||
|
|
||||||
@ -26,9 +26,10 @@ export function onceCell<T>(builder: () => T): OnceCell<T> {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
value = builder();
|
||||||
called = true;
|
called = true;
|
||||||
|
|
||||||
return value = builder();
|
return value;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import path from "path";
|
|||||||
import { SemVer } from "semver";
|
import { SemVer } from "semver";
|
||||||
import packageInfo from "../../package.json";
|
import packageInfo from "../../package.json";
|
||||||
import { defineGlobal } from "./utils/defineGlobal";
|
import { defineGlobal } from "./utils/defineGlobal";
|
||||||
import { onceCell } from "./utils/once-cell";
|
import { lazyInitialized } from "./utils/once-cell";
|
||||||
|
|
||||||
export const isMac = process.platform === "darwin";
|
export const isMac = process.platform === "darwin";
|
||||||
export const isWindows = process.platform === "win32";
|
export const isWindows = process.platform === "win32";
|
||||||
@ -66,18 +66,18 @@ export function getBinaryName(name: string, { forPlatform = normalizedPlatform }
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const resourcesDir = onceCell(() => (
|
const resourcesDir = lazyInitialized(() => (
|
||||||
isProduction
|
isProduction
|
||||||
? process.resourcesPath
|
? process.resourcesPath
|
||||||
: path.join(process.cwd(), "binaries", "client", normalizedPlatform)
|
: path.join(process.cwd(), "binaries", "client", normalizedPlatform)
|
||||||
));
|
));
|
||||||
|
|
||||||
export const baseBinariesDir = onceCell(() => path.join(resourcesDir.get(), normalizedArch));
|
export const baseBinariesDir = lazyInitialized(() => path.join(resourcesDir.get(), normalizedArch));
|
||||||
|
export const kubeAuthProxyBinaryName = getBinaryName("lens-k8s-proxy");
|
||||||
export const helmBinaryName = getBinaryName("helm");
|
export const helmBinaryName = getBinaryName("helm");
|
||||||
export const helmBinaryPath = onceCell(() => path.join(resourcesDir.get(), helmBinaryName));
|
export const helmBinaryPath = lazyInitialized(() => path.join(baseBinariesDir.get(), helmBinaryName));
|
||||||
export const kubectlBinaryName = getBinaryName("kubectl");
|
export const kubectlBinaryName = getBinaryName("kubectl");
|
||||||
export const kubectlBinaryPath = onceCell(() => path.join(baseBinariesDir.get(), kubectlBinaryName));
|
export const kubectlBinaryPath = lazyInitialized(() => path.join(baseBinariesDir.get(), kubectlBinaryName));
|
||||||
|
|
||||||
// Webpack build paths
|
// Webpack build paths
|
||||||
export const contextDir = process.cwd();
|
export const contextDir = process.cwd();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user