feat: Compute the kubectl download version map at build time

- Allows for bundled kubectl config to be changed without code changes

- Introduce @k8slens/kubectl-versions

  - Compile time fetching of versions

- Update @swc/* packages

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2023-04-14 14:42:00 -04:00
1 parent 2debe61359
commit 0bd7b1fe92
26 files changed
+348 -70

No files matched your search

+2 -1
View File
@@ -184,7 +184,7 @@
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60",
"@sentry/types": "^6.19.7",
"@swc/cli": "^0.1.61",
"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.44",
"@swc/jest": "^0.2.24",
"@testing-library/dom": "^8.19.0",
@@ -313,6 +313,7 @@
"@k8slens/application": "^6.5.0-alpha.0",
"@k8slens/application-for-electron-main": "^6.5.0-alpha.0",
"@k8slens/cluster-settings": "^6.5.0-alpha.1",
"@k8slens/kubectl-versions": "^6.5.0-alpha.1",
"@k8slens/legacy-extensions": "^1.0.0-alpha.0",
"@k8slens/messaging": "^1.0.0-alpha.1",
"@k8slens/messaging-for-main": "^1.0.0-alpha.1",
@@ -34,7 +34,7 @@ const createKubectlInjectable = getInjectable({
normalizedDownloadPlatform: di.inject(normalizedPlatformInjectable),
kubectlBinaryName: di.inject(kubectlBinaryNameInjectable),
bundledKubectlBinaryPath: di.inject(bundledKubectlBinaryPathInjectable),
baseBundeledBinariesDirectory: di.inject(baseBundledBinariesDirectoryInjectable),
baseBundledBinariesDirectory: di.inject(baseBundledBinariesDirectoryInjectable),
bundledKubectlVersion: di.inject(bundledKubectlVersionInjectable),
kubectlVersionMap: di.inject(kubectlVersionMapInjectable),
logger: di.inject(loggerInjectable),
+2 -2
View File
@@ -29,7 +29,7 @@ export interface KubectlDependencies {
readonly normalizedDownloadArch: "amd64" | "arm64" | "386";
readonly kubectlBinaryName: string;
readonly bundledKubectlBinaryPath: string;
readonly baseBundeledBinariesDirectory: string;
readonly baseBundledBinariesDirectory: string;
readonly state: {
readonly kubectlBinariesPath?: string;
readonly downloadBinariesPath?: string;
@@ -302,7 +302,7 @@ export class Kubectl {
}
protected async writeInitScripts() {
const binariesDir = this.dependencies.baseBundeledBinariesDirectory;
const binariesDir = this.dependencies.baseBundledBinariesDirectory;
const kubectlPath = this.dependencies.state.downloadKubectlBinaries
? this.dirname
: this.dependencies.getDirnameOfPath(this.getPathFromPreferences());
@@ -3,31 +3,19 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { SemVer } from "semver";
import bundledKubectlVersionInjectable from "../../common/vars/bundled-kubectl-version.injectable";
import { kubectlVersions } from "@k8slens/kubectl-versions";
const kubectlVersionMapInjectable = getInjectable({
id: "kubectl-version-map",
instantiate: (di) => {
const bundledKubectlVersion = di.inject(bundledKubectlVersionInjectable);
const bundledKubectlSemVer = new SemVer(bundledKubectlVersion);
return new Map([
["1.7", "1.8.15"],
["1.8", "1.9.10"],
["1.9", "1.10.13"],
["1.10", "1.11.10"],
["1.11", "1.12.10"],
["1.12", "1.13.12"],
["1.13", "1.13.12"],
["1.14", "1.14.10"],
["1.15", "1.15.11"],
["1.16", "1.16.15"],
["1.17", "1.17.17"],
["1.18", "1.18.20"],
["1.19", "1.19.12"],
["1.20", "1.20.8"],
["1.21", "1.21.9"],
["1.22", "1.22.6"],
["1.23", bundledKubectlVersion],
...kubectlVersions,
[`${bundledKubectlSemVer.major}.${bundledKubectlSemVer.minor}`, bundledKubectlVersion],
]);
},
});