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

@@ -3,9 +3,9 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import yaml from "js-yaml";
import { apiBaseInjectionToken } from "../../api-base";
import { urlBuilderFor } from "../../../utils/buildUrl";
import type { AsyncResult } from "../../../utils/async-result";
interface HelmReleaseUpdatePayload {
repo: string;
@@ -18,7 +18,7 @@ export type RequestHelmReleaseUpdate = (
name: string,
namespace: string,
payload: HelmReleaseUpdatePayload
) => Promise<{ updateWasSuccessful: true } | { updateWasSuccessful: false; error: unknown }>;
) => Promise<AsyncResult<void, unknown>>;
const requestUpdateEndpoint = urlBuilderFor("/v2/releases/:namespace/:name");
@@ -28,20 +28,20 @@ const requestHelmReleaseUpdateInjectable = getInjectable({
instantiate: (di): RequestHelmReleaseUpdate => {
const apiBase = di.inject(apiBaseInjectionToken);
return async (name, namespace, { repo, chart, values, ...data }) => {
return async (name, namespace, { repo, chart, values, version }) => {
try {
await apiBase.put(requestUpdateEndpoint.compile({ name, namespace }), {
data: {
chart: `${repo}/${chart}`,
values: yaml.load(values),
...data,
values,
version,
},
});
} catch (e) {
return { updateWasSuccessful: false, error: e };
return { callWasSuccessful: false, error: e };
}
return { updateWasSuccessful: true };
return { callWasSuccessful: true };
};
},
});