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

Return parsed object

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala 2021-01-26 11:31:41 +02:00
parent aaff71e0b0
commit f3b1edca28
2 changed files with 8 additions and 5 deletions

View File

@ -96,8 +96,7 @@ describe("Lens integration tests", () => {
}); });
it("ensures helm repos", async () => { it("ensures helm repos", async () => {
const reposJson = await listHelmRepositories(); const repos = await listHelmRepositories();
const repos = JSON.parse(reposJson);
if (!repos[0]) { if (!repos[0]) {
fail("Lens failed to add Bitnami repository"); fail("Lens failed to add Bitnami repository");

View File

@ -28,6 +28,10 @@ export function setup(): Application {
}); });
} }
type HelmRepository = {
name: string;
url: string;
};
type AsyncPidGetter = () => Promise<number>; type AsyncPidGetter = () => Promise<number>;
export const promiseExec = util.promisify(exec); export const promiseExec = util.promisify(exec);
@ -43,12 +47,12 @@ export async function tearDown(app: Application) {
} }
} }
export async function listHelmRepositories(retries = 0): Promise<string> { export async function listHelmRepositories(retries = 0): Promise<HelmRepository[]>{
if (retries < 5) { if (retries < 5) {
try { try {
const { stdout: reposJson } = await promiseExec("helm repo list -o json"); const { stdout: reposJson } = await promiseExec("helm repo list -o json");
return reposJson; return JSON.parse(reposJson);
} catch { } catch {
await new Promise(r => setTimeout(r, 2000)); // if no repositories, wait for Lens adding bitnami repository await new Promise(r => setTimeout(r, 2000)); // if no repositories, wait for Lens adding bitnami repository
@ -56,5 +60,5 @@ export async function listHelmRepositories(retries = 0): Promise<string> {
} }
} }
return "[]"; return [];
} }