mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix downloading cluster specific kubectl (#5399)
This commit is contained in:
1 parent
ac27077ef9
commit
e1c1e00a2b
22 files changed
+251
-63
No files matched your search
@@ -22,6 +22,9 @@ import getConfigurationFileModelInjectable from "../get-configuration-file-model
|
||||
import appVersionInjectable from "../get-configuration-file-model/app-version/app-version.injectable";
|
||||
import assert from "assert";
|
||||
import directoryForTempInjectable from "../app-paths/directory-for-temp/directory-for-temp.injectable";
|
||||
import kubectlBinaryNameInjectable from "../../main/kubectl/binary-name.injectable";
|
||||
import kubectlDownloadingNormalizedArchInjectable from "../../main/kubectl/normalized-arch.injectable";
|
||||
import normalizedPlatformInjectable from "../vars/normalized-platform.injectable";
|
||||
|
||||
console = new Console(stdout, stderr);
|
||||
|
||||
@@ -84,6 +87,9 @@ describe("cluster-store", () => {
|
||||
|
||||
mainDi.override(directoryForUserDataInjectable, () => "some-directory-for-user-data");
|
||||
mainDi.override(directoryForTempInjectable, () => "some-temp-directory");
|
||||
mainDi.override(kubectlBinaryNameInjectable, () => "kubectl");
|
||||
mainDi.override(kubectlDownloadingNormalizedArchInjectable, () => "amd64");
|
||||
mainDi.override(normalizedPlatformInjectable, () => "darwin");
|
||||
|
||||
mainDi.permitSideEffects(getConfigurationFileModelInjectable);
|
||||
mainDi.permitSideEffects(appVersionInjectable);
|
||||
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { baseBinariesDir } from "../../vars";
|
||||
|
||||
const directoryForBundledBinariesInjectable = getInjectable({
|
||||
id: "directory-for-bundled-binaries",
|
||||
instantiate: () => baseBinariesDir.get(),
|
||||
});
|
||||
|
||||
export default directoryForBundledBinariesInjectable;
|
||||
+6
-10
@@ -57,6 +57,9 @@ export const defaultThemeId: ThemeId = "lens-dark";
|
||||
export const defaultFontSize = 12;
|
||||
export const defaultTerminalFontFamily = "RobotoMono";
|
||||
export const defaultEditorFontFamily = "RobotoMono";
|
||||
/**
|
||||
* @deprecated use `di.inject(normalizedPlatformInjectable)` instead
|
||||
*/
|
||||
export const normalizedPlatform = (() => {
|
||||
switch (process.platform) {
|
||||
case "darwin":
|
||||
@@ -69,6 +72,9 @@ export const normalizedPlatform = (() => {
|
||||
throw new Error(`platform=${process.platform} is unsupported`);
|
||||
}
|
||||
})();
|
||||
/**
|
||||
* @deprecated use `di.inject(bundledBinariesNormalizedArchInjectable)` instead
|
||||
*/
|
||||
export const normalizedArch = (() => {
|
||||
switch (process.arch) {
|
||||
case "arm64":
|
||||
@@ -119,16 +125,6 @@ export const helmBinaryName = getBinaryName("helm");
|
||||
*/
|
||||
export const helmBinaryPath = lazyInitialized(() => path.join(baseBinariesDir.get(), helmBinaryName));
|
||||
|
||||
/**
|
||||
* @deprecated for being explicit side effect.
|
||||
*/
|
||||
export const kubectlBinaryName = getBinaryName("kubectl");
|
||||
|
||||
/**
|
||||
* @deprecated for being explicit side effect.
|
||||
*/
|
||||
export const kubectlBinaryPath = lazyInitialized(() => path.join(baseBinariesDir.get(), kubectlBinaryName));
|
||||
|
||||
// Apis
|
||||
export const apiPrefix = "/api"; // local router apis
|
||||
export const apiKubePrefix = "/api-kube"; // k8s cluster apis
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import path from "path";
|
||||
import bundledBinariesNormalizedArchInjectable from "./bundled-binaries-normalized-arch.injectable";
|
||||
import bundledResourcesDirectoryInjectable from "./bundled-resources-dir.injectable";
|
||||
|
||||
const baseBundeledBinariesDirectoryInjectable = getInjectable({
|
||||
id: "base-bundeled-binaries-directory",
|
||||
instantiate: (di) => path.join(
|
||||
di.inject(bundledResourcesDirectoryInjectable),
|
||||
di.inject(bundledBinariesNormalizedArchInjectable),
|
||||
),
|
||||
});
|
||||
|
||||
export default baseBundeledBinariesDirectoryInjectable;
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
|
||||
const bundledBinariesNormalizedArchInjectable = getInjectable({
|
||||
id: "bundled-binaries-normalized-arch",
|
||||
instantiate: () => {
|
||||
switch (process.arch) {
|
||||
case "arm64":
|
||||
return "arm64";
|
||||
case "x64":
|
||||
case "amd64":
|
||||
return "x64";
|
||||
case "386":
|
||||
case "x32":
|
||||
case "ia32":
|
||||
return "ia32";
|
||||
default:
|
||||
throw new Error(`arch=${process.arch} is unsupported`);
|
||||
}
|
||||
},
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
export default bundledBinariesNormalizedArchInjectable;
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import path from "path";
|
||||
import isProductionInjectable from "./is-production.injectable";
|
||||
import normalizedPlatformInjectable from "./normalized-platform.injectable";
|
||||
|
||||
const bundledResourcesDirectoryInjectable = getInjectable({
|
||||
id: "bundled-resources-directory",
|
||||
instantiate: (di) => {
|
||||
const isProduction = di.inject(isProductionInjectable);
|
||||
const normalizedPlatform = di.inject(normalizedPlatformInjectable);
|
||||
|
||||
return isProduction
|
||||
? process.resourcesPath
|
||||
: path.join(process.cwd(), "binaries", "client", normalizedPlatform);
|
||||
},
|
||||
});
|
||||
|
||||
export default bundledResourcesDirectoryInjectable;
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
|
||||
const normalizedPlatformInjectable = getInjectable({
|
||||
id: "normalized-platform",
|
||||
instantiate: () => {
|
||||
switch (process.platform) {
|
||||
case "darwin":
|
||||
return "darwin";
|
||||
case "linux":
|
||||
return "linux";
|
||||
case "win32":
|
||||
return "windows";
|
||||
default:
|
||||
throw new Error(`platform=${process.platform} is unsupported`);
|
||||
}
|
||||
},
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
export default normalizedPlatformInjectable;
|
||||
Reference in new issue
Block a user