1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/main/helm/exec-helm/exec-helm.injectable.ts
Janne Savolainen ec78080d99
Make opening of release details work properly when release has resources without namespace (#6088)
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>
Co-authored-by: Sebastian Malton <sebastian@malton.name>
2022-09-08 13:57:11 -04:00

36 lines
1.1 KiB
TypeScript

/**
* 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 execFileInjectable from "../../../common/fs/exec-file.injectable";
import helmBinaryPathInjectable from "../helm-binary-path.injectable";
import type { AsyncResult } from "../../../common/utils/async-result";
import { getErrorMessage } from "../../../common/utils/get-error-message";
export type ExecHelm = (args: string[]) => Promise<AsyncResult<string>>;
const execHelmInjectable = getInjectable({
id: "exec-helm",
instantiate: (di): ExecHelm => {
const execFile = di.inject(execFileInjectable);
const helmBinaryPath = di.inject(helmBinaryPathInjectable);
return async (args) => {
try {
const response = await execFile(helmBinaryPath, args, {
maxBuffer: 32 * 1024 * 1024 * 1024, // 32 MiB
});
return { callWasSuccessful: true, response };
} catch (error) {
return { callWasSuccessful: false, error: getErrorMessage(error) };
}
};
},
});
export default execHelmInjectable;