Skip to content

Commit

Permalink
Update bundled binaries (#33)
Browse files Browse the repository at this point in the history
* Update bundled binaries
* Bump minikube
* Show error on failure
* Show full URL on download, switch to new URL for kubectl
  • Loading branch information
dex4er authored Oct 15, 2024
1 parent aad2950 commit 2a44cbf
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
if: runner.os == 'Linux'
uses: medyagh/setup-minikube@master
with:
kubernetes-version: v1.30.1
kubernetes-version: v1.31.0

- name: Install NPM dependencies
uses: nick-fields/retry@v3
Expand Down
6 changes: 3 additions & 3 deletions freelens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"postinstall": "electron-rebuild"
},
"config": {
"k8sProxyVersion": "1.0.0",
"bundledKubectlVersion": "1.23.3",
"bundledHelmVersion": "3.11.0",
"k8sProxyVersion": "1.1.0",
"bundledKubectlVersion": "1.31.1",
"bundledHelmVersion": "3.16.2",
"sentryDsn": "",
"contentSecurityPolicy": "script-src 'unsafe-eval' 'self'; frame-src https://*.lens.app:*/; img-src * data:",
"welcomeRoute": "/welcome"
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
"lint:fix": "npm run lint -- --fix"
},
"config": {
"k8sProxyVersion": "0.3.0",
"bundledKubectlVersion": "1.23.3",
"bundledHelmVersion": "3.11.0",
"k8sProxyVersion": "1.1.0",
"bundledKubectlVersion": "1.31.1",
"bundledHelmVersion": "3.16.2",
"sentryDsn": "",
"contentSecurityPolicy": "script-src 'unsafe-eval' 'self'; frame-src https://*.lens.app:*/; img-src * data:",
"welcomeRoute": "/welcome"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
* Copyright (c) Freelens Authors. All rights reserved.
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
Expand Down Expand Up @@ -60,7 +61,7 @@ export interface DownloadMirror {

export const defaultPackageMirror = "default";
const defaultDownloadMirrorData: DownloadMirror = {
url: "https://storage.googleapis.com/kubernetes-release/release",
url: "https://dl.k8s.io/release",
label: "Default (Google)",
platforms: new Set(["darwin", "win32", "linux"]),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export const applicationInformationFakeInjectable = getInjectable({
productName: "some-product-name",
version: "6.0.0",
updatingIsEnabled: false,
k8sProxyVersion: "0.2.1",
bundledKubectlVersion: "1.23.3",
bundledHelmVersion: "3.7.2",
k8sProxyVersion: "1.1.0",
bundledKubectlVersion: "1.31.1",
bundledHelmVersion: "3.16.2",
sentryDsn: "",
contentSecurityPolicy: "script-src 'unsafe-eval' 'self'; frame-src http://*.localhost:*/; img-src * data:",
welcomeRoute: "/welcome",
Expand Down
51 changes: 31 additions & 20 deletions packages/ensure-binaries/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node
/**
* Copyright (c) Freelens Authors. All rights reserved.
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
Expand All @@ -26,7 +27,7 @@ const options = arg({

type Options = typeof options;

const assertOption = <Key extends keyof Options>(key: Key): NonNullable<Options[Key]> => {
function assertOption<Key extends keyof Options>(key: Key): NonNullable<Options[Key]> {
const raw = options[key];

if (raw === undefined) {
Expand All @@ -37,7 +38,7 @@ const assertOption = <Key extends keyof Options>(key: Key): NonNullable<Options[
return raw;
};

const joinWithInitCwd = (relativePath: string): string => {
function joinWithInitCwd(relativePath: string): string {
const { INIT_CWD } = process.env;

if (!INIT_CWD) {
Expand All @@ -58,13 +59,13 @@ function setTimeoutFor(controller: AbortController, timeout: number): void {

const pipeline = promisify(_pipeline);

const getBinaryName = (binaryName: string, { forPlatform }: { forPlatform : string }) => {
function getBinaryExtension({ forPlatform }: { forPlatform : string }): string {
if (forPlatform === "windows") {
return `${binaryName}.exe`;
return ".exe";
}

return binaryName;
};
return "";
}

interface BinaryDownloaderArgs {
readonly version: string;
Expand All @@ -73,6 +74,7 @@ interface BinaryDownloaderArgs {
readonly fileArch: string;
readonly binaryName: string;
readonly baseDir: string;
readonly url: string;
}

abstract class BinaryDownloader {
Expand Down Expand Up @@ -101,6 +103,11 @@ abstract class BinaryDownloader {
const stream = await fetch(this.url, {
signal: controller.signal,
});

if (!stream.ok) {
throw new Error(`${this.url}: ${stream.status} ${stream.statusText}`);
}

const total = Number(stream.headers.get("content-length"));
const bar = this.bar;
let fileHandle: FileHandle | undefined = undefined;
Expand Down Expand Up @@ -163,33 +170,37 @@ abstract class BinaryDownloader {
class FreeLensK8sProxyDownloader extends BinaryDownloader {
protected readonly url: string;

constructor(args: Omit<BinaryDownloaderArgs, "binaryName">, bar: MultiBar) {
const binaryName = getBinaryName("freelens-k8s-proxy", { forPlatform: args.platform });
constructor(args: Omit<BinaryDownloaderArgs, "binaryName" | "url">, bar: MultiBar) {
const binaryExtension = getBinaryExtension({ forPlatform: args.platform });
const binaryName = "freelens-k8s-proxy" + binaryExtension;
const url = `https://github.com/freelensapp/freelens-k8s-proxy/releases/download/v${args.version}/freelens-k8s-proxy-${args.platform}-${args.downloadArch}${binaryExtension}`;

super({ ...args, binaryName }, bar);
this.url = `https://github.com/freelensapp/freelens-k8s-proxy/releases/download/v${args.version}/freelens-k8s-proxy-${args.platform}-${args.downloadArch}`;
super({ ...args, binaryName, url }, bar);
this.url = url;
}
}

class KubectlDownloader extends BinaryDownloader {
protected readonly url: string;

constructor(args: Omit<BinaryDownloaderArgs, "binaryName">, bar: MultiBar) {
const binaryName = getBinaryName("kubectl", { forPlatform: args.platform });
constructor(args: Omit<BinaryDownloaderArgs, "binaryName" | "url">, bar: MultiBar) {
const binaryName = "kubectl" + getBinaryExtension({ forPlatform: args.platform });
const url = `https://dl.k8s.io/release/v${args.version}/bin/${args.platform}/${args.downloadArch}/${binaryName}`;
super({ ...args, binaryName }, bar);
this.url = `https://storage.googleapis.com/kubernetes-release/release/v${args.version}/bin/${args.platform}/${args.downloadArch}/${binaryName}`;
super({ ...args, binaryName, url }, bar);
this.url = url;
}
}
class HelmDownloader extends BinaryDownloader {
protected readonly url: string;
constructor(args: Omit<BinaryDownloaderArgs, "binaryName">, bar: MultiBar) {
const binaryName = getBinaryName("helm", { forPlatform: args.platform });
constructor(args: Omit<BinaryDownloaderArgs, "binaryName" | "url">, bar: MultiBar) {
const binaryName = "helm" + getBinaryExtension({ forPlatform: args.platform });
const url = `https://get.helm.sh/helm-v${args.version}-${args.platform}-${args.downloadArch}.tar.gz`;
super({ ...args, binaryName }, bar);
this.url = `https://get.helm.sh/helm-v${args.version}-${args.platform}-${args.downloadArch}.tar.gz`;
super({ ...args, binaryName, url }, bar);
this.url = url;
}
protected getTransformStreams(file: WriteStream) {
Expand Down Expand Up @@ -244,7 +255,7 @@ const multiBar = new MultiBar({
hideCursor: true,
autopadding: true,
noTTYOutput: true,
format: "[{bar}] {percentage}% | {downloadArch} {binaryName}",
format: "[{bar}] {percentage}% | {url}",
});
const downloaders: BinaryDownloader[] = [];
Expand Down Expand Up @@ -275,7 +286,7 @@ const downloadX64Binaries = () => {
);
}
const downloadArm64Binaries = () => {
function downloadArm64Binaries() {
downloaders.push(
new FreeLensK8sProxyDownloader({
version: packageInfo.config.k8sProxyVersion,
Expand Down
8 changes: 4 additions & 4 deletions packages/kubectl-versions/build/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,18 @@
],
[
"1.28",
"1.28.13"
"1.28.14"
],
[
"1.29",
"1.29.8"
"1.29.9"
],
[
"1.30",
"1.30.4"
"1.30.5"
],
[
"1.31",
"1.31.0"
"1.31.1"
]
]

0 comments on commit 2a44cbf

Please sign in to comment.