mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Make sure release details are updates when opening details Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Relax filtering of resources to prevent crashing when release has installed resources in another namespace Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Add Open Closed Principle compliant way to introduce global overrides without modification in getDiForUnitTesting Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Rework helm release details to fix multiple bugs Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Remove redundant optional chaining Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Simplify code Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import yaml from "js-yaml";
|
|
import { getInjectable } from "@ogre-tools/injectable";
|
|
import type { HelmReleaseUpdateDetails } from "../../../../common/k8s-api/endpoints/helm-releases.api";
|
|
import { endpoint } from "../../../../common/k8s-api/endpoints/helm-releases.api";
|
|
import { apiBase } from "../../../../common/k8s-api";
|
|
|
|
interface HelmReleaseCreatePayload {
|
|
name?: string;
|
|
repo: string;
|
|
chart: string;
|
|
namespace: string;
|
|
version: string;
|
|
values: string;
|
|
}
|
|
|
|
export type CallForCreateHelmRelease = (
|
|
payload: HelmReleaseCreatePayload
|
|
) => Promise<HelmReleaseUpdateDetails>;
|
|
|
|
const callForCreateHelmReleaseInjectable = getInjectable({
|
|
id: "call-for-create-helm-release",
|
|
|
|
instantiate: (): CallForCreateHelmRelease => (payload) => {
|
|
const { repo, chart: rawChart, values: rawValues, ...data } = payload;
|
|
const chart = `${repo}/${rawChart}`;
|
|
const values = yaml.load(rawValues);
|
|
|
|
return apiBase.post(endpoint(), {
|
|
data: {
|
|
chart,
|
|
values,
|
|
...data,
|
|
},
|
|
});
|
|
},
|
|
|
|
causesSideEffects: true,
|
|
});
|
|
|
|
export default callForCreateHelmReleaseInjectable;
|