Fix crash when upgrading release (#6626)

* Fix crash when upgrading release

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix crash when upgrading helm releases

- Fixes not being able to upgrade helm releases as well.

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix tests

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix test failures

Signed-off-by: Sebastian Malton <sebastian@malton.name>

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2022-11-23 03:38:37 -08:00
1 parent 1354fa66a5
commit 573cd83bfb
16 files changed
+146 -68

No files matched your search

@@ -0,0 +1,10 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { computed } from "mobx";
import { getGlobalOverride } from "../../../common/test-utils/get-global-override";
import execHelmEnvInjectable from "./exec-env.injectable";
export default getGlobalOverride(execHelmEnvInjectable, () => computed(() => ({})));
@@ -0,0 +1,26 @@
/**
* 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 { computed } from "mobx";
import userStoreInjectable from "../../../common/user-store/user-store.injectable";
const execHelmEnvInjectable = getInjectable({
id: "exec-helm-env",
instantiate: (di) => {
const userStore = di.inject(userStoreInjectable);
return computed(() => {
const {
HTTPS_PROXY = userStore.httpsProxy,
...env
} = process.env;
return { HTTPS_PROXY, ...env } as Partial<Record<string, string>>;
});
},
causesSideEffects: true,
});
export default execHelmEnvInjectable;
@@ -7,6 +7,7 @@ import type { ExecFileException } from "child_process";
import execFileInjectable from "../../../common/fs/exec-file.injectable";
import type { AsyncResult } from "../../../common/utils/async-result";
import helmBinaryPathInjectable from "../helm-binary-path.injectable";
import execHelmEnvInjectable from "./exec-env.injectable";
export type ExecHelm = (args: string[]) => Promise<AsyncResult<string, ExecFileException & { stderr: string }>>;
@@ -15,10 +16,12 @@ const execHelmInjectable = getInjectable({
instantiate: (di): ExecHelm => {
const execFile = di.inject(execFileInjectable);
const execHelmEnv = di.inject(execHelmEnvInjectable);
const helmBinaryPath = di.inject(helmBinaryPathInjectable);
return async (args) => execFile(helmBinaryPath, args, {
maxBuffer: 32 * 1024 * 1024 * 1024, // 32 MiB
env: execHelmEnv.get(),
});
},
});