From f89e61b2b42e77d89f89035d113e25ab2360bd9c Mon Sep 17 00:00:00 2001 From: Asa Gayle Date: Tue, 25 Jan 2022 16:07:01 -0500 Subject: [PATCH] fixed method to access helm releses JSON --- lib/run.js | 10 +++++----- src/run.ts | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/run.js b/lib/run.js index 89ca79a..eba26ab 100644 --- a/lib/run.js +++ b/lib/run.js @@ -90,12 +90,12 @@ function getLatestHelmVersion() { return __awaiter(this, void 0, void 0, function* () { let helmJSONPath = yield toolCache.downloadTool(helmAllReleasesUrl); try { - const helmJSONArray = JSON.parse(fs.readFileSync(helmJSONPath, 'utf-8')); - helmJSONArray.forEach(ver => { - if (isValidVersion(ver["tag_name"])) { - return ver; + const helmJSON = JSON.parse(fs.readFileSync(helmJSONPath, 'utf-8')); + for (let i in helmJSON) { + if (isValidVersion(helmJSON[i].tag_name)) { + return helmJSON[i].tag_name; } - }); + } } catch (err) { core.warning(util.format("Error while fetching the latest Helm release. Error: %s. Using default Helm version %s", err.toString(), stableHelmVersion)); diff --git a/src/run.ts b/src/run.ts index 3f4ff75..c13404e 100644 --- a/src/run.ts +++ b/src/run.ts @@ -85,12 +85,12 @@ export async function getLatestHelmVersion(): Promise { let helmJSONPath:string = await toolCache.downloadTool(helmAllReleasesUrl); try{ - const helmJSONArray = JSON.parse(fs.readFileSync(helmJSONPath, 'utf-8')) - helmJSONArray.forEach(ver => { - if(isValidVersion(ver["tag_name"])){ - return ver; + const helmJSON = JSON.parse(fs.readFileSync(helmJSONPath, 'utf-8')) + for(let i in helmJSON){ + if(isValidVersion(helmJSON[i].tag_name)){ + return helmJSON[i].tag_name; } - }); + } } catch(err){ core.warning(util.format("Error while fetching the latest Helm release. Error: %s. Using default Helm version %s", err.toString(), stableHelmVersion)); return stableHelmVersion;