1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Move clearKubeconfigEnvVars to separate file (#2337)

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-03-16 08:05:28 -04:00 committed by GitHub
parent 6c872c1aad
commit 7d14ba5e48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 18 deletions

View File

@ -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", () => {

View File

@ -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<string, any>): Record<string, any> {
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<string, any> = new Map();

View File

@ -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<string, any>): Record<string, any> {
return Object.fromEntries(
Object.entries(env)
.filter(([key]) => anyKubeconfig.exec(key) === null)
);
}