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

Fix startup due to buildVersion dependency

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-10-12 14:24:16 -04:00
parent 8cf435d2fb
commit d2d546342e
5 changed files with 9 additions and 8 deletions

View File

@ -7,14 +7,14 @@ import { clearKubeconfigEnvVars } from "../utils/clear-kube-env-vars";
describe("clearKubeconfigEnvVars tests", () => {
it("should not touch non kubeconfig keys", () => {
expect(clearKubeconfigEnvVars({ a: 1 })).toStrictEqual({ a: 1 });
expect(clearKubeconfigEnvVars({ a: "22" })).toStrictEqual({ a: "22" });
});
it("should remove a single kubeconfig key", () => {
expect(clearKubeconfigEnvVars({ a: 1, kubeconfig: "1" })).toStrictEqual({ a: 1 });
expect(clearKubeconfigEnvVars({ a: "22", kubeconfig: "1" })).toStrictEqual({ a: "22" });
});
it("should remove a two kubeconfig key", () => {
expect(clearKubeconfigEnvVars({ a: 1, kubeconfig: "1", kUbeconfig: "1" })).toStrictEqual({ a: 1 });
expect(clearKubeconfigEnvVars({ a: "22", kubeconfig: "1", kUbeconfig: "1" })).toStrictEqual({ a: "22" });
});
});

View File

@ -44,7 +44,7 @@ const openLocalShellSessionInjectable = getInjectable({
userStore: di.inject(userStoreInjectable),
resolvedShell: di.inject(resolvedShellInjectable),
appName: di.inject(appNameInjectable),
buildVersion: di.inject(buildVersionInjectable).get(),
buildVersion: di.inject(buildVersionInjectable),
modifyTerminalShellEnv: di.inject(modifyTerminalShellEnvInjectable),
getDirnameOfPath: di.inject(getDirnameOfPathInjectable),
joinPaths: di.inject(joinPathsInjectable),

View File

@ -35,7 +35,7 @@ const openNodeShellSessionInjectable = getInjectable({
logger: di.inject(loggerInjectable),
resolvedShell: di.inject(resolvedShellInjectable),
appName: di.inject(appNameInjectable),
buildVersion: di.inject(buildVersionInjectable).get(),
buildVersion: di.inject(buildVersionInjectable),
createKubeJsonApiForCluster: di.inject(createKubeJsonApiForClusterInjectable),
computeShellEnvironment: di.inject(computeShellEnvironmentInjectable),
spawnPty: di.inject(spawnPtyInjectable),

View File

@ -17,6 +17,7 @@ import { type TerminalMessage, TerminalChannels } from "../../common/terminal/ch
import type { Logger } from "../../common/logger";
import type { ComputeShellEnvironment } from "../utils/shell-env/compute-shell-environment.injectable";
import type { SpawnPty } from "./spawn-pty.injectable";
import type { InitializableState } from "../../common/initializable-state/create";
export class ShellOpenError extends Error {
constructor(message: string, options?: ErrorOptions) {
@ -108,7 +109,7 @@ export interface ShellSessionDependencies {
readonly logger: Logger;
readonly resolvedShell: string | undefined;
readonly appName: string;
readonly buildVersion: string;
readonly buildVersion: InitializableState<string>;
computeShellEnvironment: ComputeShellEnvironment;
spawnPty: SpawnPty;
}
@ -376,7 +377,7 @@ export abstract class ShellSession {
env.PTYPID = process.pid.toString();
env.KUBECONFIG = await this.kubeconfigPathP;
env.TERM_PROGRAM = this.dependencies.appName;
env.TERM_PROGRAM_VERSION = this.dependencies.buildVersion;
env.TERM_PROGRAM_VERSION = this.dependencies.buildVersion.get();
if (this.cluster.preferences.httpsProxy) {
env.HTTPS_PROXY = this.cluster.preferences.httpsProxy;

View File

@ -13,7 +13,7 @@ const anyKubeconfig = /^kubeconfig$/i;
* before KUBECONFIG and we only set KUBECONFIG.
* @param env The current copy of env
*/
export function clearKubeconfigEnvVars(env: Record<string, any>): Record<string, any> {
export function clearKubeconfigEnvVars(env: Partial<Record<string, string>>): Partial<Record<string, string>> {
return Object.fromEntries(
Object.entries(env)
.filter(([key]) => anyKubeconfig.exec(key) === null),