From 844b43f435c0026cfd4fbd0724e78d68a2fb93af Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Mon, 15 Mar 2021 11:28:14 -0400 Subject: [PATCH 1/5] Fix Lens not clearing other KUBECONFIG env vars (#2297) --- src/main/__test__/shell-session.test.ts | 19 +++++++++++++++++++ src/main/shell-session.ts | 19 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/main/__test__/shell-session.test.ts diff --git a/src/main/__test__/shell-session.test.ts b/src/main/__test__/shell-session.test.ts new file mode 100644 index 0000000000..fe1b0c4288 --- /dev/null +++ b/src/main/__test__/shell-session.test.ts @@ -0,0 +1,19 @@ +/** + * @jest-environment jsdom + */ + +import { clearKubeconfigEnvVars } from "../shell-session"; + +describe("clearKubeconfigEnvVars tests", () => { + it("should not touch non kubeconfig keys", () => { + expect(clearKubeconfigEnvVars({ a: 1 })).toStrictEqual({ a: 1 }); + }); + + it("should remove a single kubeconfig key", () => { + expect(clearKubeconfigEnvVars({ a: 1, kubeconfig: "1" })).toStrictEqual({ a: 1 }); + }); + + it("should remove a two kubeconfig key", () => { + expect(clearKubeconfigEnvVars({ a: 1, kubeconfig: "1", kUbeconfig: "1" })).toStrictEqual({ a: 1 }); + }); +}); diff --git a/src/main/shell-session.ts b/src/main/shell-session.ts index 10a2f9ed47..e11804ac16 100644 --- a/src/main/shell-session.ts +++ b/src/main/shell-session.ts @@ -12,6 +12,23 @@ import { isWindows } from "../common/vars"; import { appEventBus } from "../common/event-bus"; import { userStore } from "../common/user-store"; +const anyKubeconfig = /^kubeconfig$/i; + +/** + * This function deletes all keys of the form /^kubeconfig$/i, returning a new + * object. + * + * This is needed because `kubectl` checks for other version of kubeconfig + * before KUBECONFIG and we only set KUBECONFIG. + * @param env The current copy of env + */ +export function clearKubeconfigEnvVars(env: Record): Record { + return Object.fromEntries( + Object.entries(env) + .filter(([key]) => anyKubeconfig.exec(key) === null) + ); +} + export class ShellSession extends EventEmitter { static shellEnvs: Map = new Map(); @@ -103,7 +120,7 @@ export class ShellSession extends EventEmitter { } protected async getShellEnv() { - const env = JSON.parse(JSON.stringify(await shellEnv())); + const env = clearKubeconfigEnvVars(JSON.parse(JSON.stringify(await shellEnv()))); const pathStr = [this.kubectlBinDir, this.helmBinDir, process.env.PATH].join(path.delimiter); if(isWindows) { From 8ce487b999243fa5b05a8b54321c918210b66432 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Tue, 16 Mar 2021 08:05:28 -0400 Subject: [PATCH 2/5] Move clearKubeconfigEnvVars to separate file (#2337) Signed-off-by: Sebastian Malton --- src/main/__test__/shell-session.test.ts | 2 +- src/main/shell-session.ts | 18 +----------------- src/main/utils/clear-kube-env-vars.ts | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 src/main/utils/clear-kube-env-vars.ts diff --git a/src/main/__test__/shell-session.test.ts b/src/main/__test__/shell-session.test.ts index fe1b0c4288..d16b5453b9 100644 --- a/src/main/__test__/shell-session.test.ts +++ b/src/main/__test__/shell-session.test.ts @@ -2,7 +2,7 @@ * @jest-environment jsdom */ -import { clearKubeconfigEnvVars } from "../shell-session"; +import { clearKubeconfigEnvVars } from "../utils/clear-kube-env-vars"; describe("clearKubeconfigEnvVars tests", () => { it("should not touch non kubeconfig keys", () => { diff --git a/src/main/shell-session.ts b/src/main/shell-session.ts index e11804ac16..5c7dca0cc6 100644 --- a/src/main/shell-session.ts +++ b/src/main/shell-session.ts @@ -11,23 +11,7 @@ import { helmCli } from "./helm/helm-cli"; import { isWindows } from "../common/vars"; import { appEventBus } from "../common/event-bus"; import { userStore } from "../common/user-store"; - -const anyKubeconfig = /^kubeconfig$/i; - -/** - * This function deletes all keys of the form /^kubeconfig$/i, returning a new - * object. - * - * This is needed because `kubectl` checks for other version of kubeconfig - * before KUBECONFIG and we only set KUBECONFIG. - * @param env The current copy of env - */ -export function clearKubeconfigEnvVars(env: Record): Record { - return Object.fromEntries( - Object.entries(env) - .filter(([key]) => anyKubeconfig.exec(key) === null) - ); -} +import { clearKubeconfigEnvVars } from "./utils/clear-kube-env-vars"; export class ShellSession extends EventEmitter { static shellEnvs: Map = new Map(); diff --git a/src/main/utils/clear-kube-env-vars.ts b/src/main/utils/clear-kube-env-vars.ts new file mode 100644 index 0000000000..ef14b1a331 --- /dev/null +++ b/src/main/utils/clear-kube-env-vars.ts @@ -0,0 +1,16 @@ +const anyKubeconfig = /^kubeconfig$/i; + +/** + * This function deletes all keys of the form /^kubeconfig$/i, returning a new + * object. + * + * This is needed because `kubectl` checks for other version of kubeconfig + * before KUBECONFIG and we only set KUBECONFIG. + * @param env The current copy of env + */ +export function clearKubeconfigEnvVars(env: Record): Record { + return Object.fromEntries( + Object.entries(env) + .filter(([key]) => anyKubeconfig.exec(key) === null) + ); +} From 75230732d15db60d77c027d673e4daddc7839daf Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Wed, 17 Mar 2021 15:13:03 +0200 Subject: [PATCH 3/5] Fix extension command palette loading (#2351) Signed-off-by: Jari Kolehmainen --- src/extensions/extension-loader.ts | 4 +++- src/extensions/registries/index.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/extensions/extension-loader.ts b/src/extensions/extension-loader.ts index 98697d252c..24951f972b 100644 --- a/src/extensions/extension-loader.ts +++ b/src/extensions/extension-loader.ts @@ -192,6 +192,7 @@ export class ExtensionLoader { registries.appPreferenceRegistry.add(extension.appPreferences), registries.clusterFeatureRegistry.add(extension.clusterFeatures), registries.statusBarRegistry.add(extension.statusBarItems), + registries.commandRegistry.add(extension.commands), ]; this.events.on("remove", (removedExtension: LensRendererExtension) => { @@ -220,7 +221,8 @@ export class ExtensionLoader { registries.clusterPageMenuRegistry.add(extension.clusterPageMenus, extension), registries.kubeObjectMenuRegistry.add(extension.kubeObjectMenuItems), registries.kubeObjectDetailRegistry.add(extension.kubeObjectDetailItems), - registries.kubeObjectStatusRegistry.add(extension.kubeObjectStatusTexts) + registries.kubeObjectStatusRegistry.add(extension.kubeObjectStatusTexts), + registries.commandRegistry.add(extension.commands), ]; this.events.on("remove", (removedExtension: LensRendererExtension) => { diff --git a/src/extensions/registries/index.ts b/src/extensions/registries/index.ts index 8e343742ec..b6838f1bab 100644 --- a/src/extensions/registries/index.ts +++ b/src/extensions/registries/index.ts @@ -9,3 +9,4 @@ export * from "./kube-object-detail-registry"; export * from "./kube-object-menu-registry"; export * from "./cluster-feature-registry"; export * from "./kube-object-status-registry"; +export * from "./command-registry"; From a0fe42708306ef6b4aa213fffd1d588ab80e6df7 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Thu, 25 Mar 2021 12:50:13 +0200 Subject: [PATCH 4/5] Proxy should listen only on loopback device (#2388) Signed-off-by: Jari Kolehmainen --- src/main/lens-proxy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/lens-proxy.ts b/src/main/lens-proxy.ts index 7e1aa98b7e..0bc3528a33 100644 --- a/src/main/lens-proxy.ts +++ b/src/main/lens-proxy.ts @@ -28,7 +28,7 @@ export class LensProxy { } listen(port = this.port): this { - this.proxyServer = this.buildCustomProxy().listen(port); + this.proxyServer = this.buildCustomProxy().listen(port, "127.0.0.1"); logger.info(`[LENS-PROXY]: Proxy server has started at ${this.origin}`); return this; From cd62ae1107a161301cf56f2e367cc80efe59968d Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Thu, 25 Mar 2021 13:10:40 +0200 Subject: [PATCH 5/5] v4.1.5 Signed-off-by: Jari Kolehmainen --- package.json | 2 +- static/RELEASE_NOTES.md | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5b2dcf58e6..13b82b15a4 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "kontena-lens", "productName": "Lens", "description": "Lens - The Kubernetes IDE", - "version": "4.1.4", + "version": "4.1.5", "main": "static/build/main.js", "copyright": "© 2020, Mirantis, Inc.", "license": "MIT", diff --git a/static/RELEASE_NOTES.md b/static/RELEASE_NOTES.md index d4344f53f2..9ef56e507e 100644 --- a/static/RELEASE_NOTES.md +++ b/static/RELEASE_NOTES.md @@ -2,7 +2,14 @@ Here you can find description of changes we've built into each release. While we try our best to make each upgrade automatic and as smooth as possible, there may be some cases where you might need to do something to ensure the application works smoothly. So please read through the release highlights! -## 4.1.4 (current version) + +## 4.1.5 (current version) + +- Fix internal proxy listening on all network interfaces +- Fix extension command palette loading +- Fix Lens not clearing other KUBECONFIG env vars + +## 4.1.4 - Ignore clusters with invalid kubeconfig - Render only secret name on pod details without access to secrets