4
0
Fork 0
mirror of https://github.com/Azure/setup-helm.git synced 2025-11-07 21:16:57 +00:00

fixed method to access helm releses JSON

This commit is contained in:
Asa Gayle 2022-01-25 16:07:01 -05:00
parent 45f20ed080
commit f89e61b2b4
2 changed files with 10 additions and 10 deletions

View file

@ -90,12 +90,12 @@ function getLatestHelmVersion() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let helmJSONPath = yield toolCache.downloadTool(helmAllReleasesUrl); let helmJSONPath = yield toolCache.downloadTool(helmAllReleasesUrl);
try { try {
const helmJSONArray = JSON.parse(fs.readFileSync(helmJSONPath, 'utf-8')); const helmJSON = JSON.parse(fs.readFileSync(helmJSONPath, 'utf-8'));
helmJSONArray.forEach(ver => { for (let i in helmJSON) {
if (isValidVersion(ver["tag_name"])) { if (isValidVersion(helmJSON[i].tag_name)) {
return ver; return helmJSON[i].tag_name;
} }
}); }
} }
catch (err) { catch (err) {
core.warning(util.format("Error while fetching the latest Helm release. Error: %s. Using default Helm version %s", err.toString(), stableHelmVersion)); core.warning(util.format("Error while fetching the latest Helm release. Error: %s. Using default Helm version %s", err.toString(), stableHelmVersion));

View file

@ -85,12 +85,12 @@ export async function getLatestHelmVersion(): Promise<string> {
let helmJSONPath:string = await toolCache.downloadTool(helmAllReleasesUrl); let helmJSONPath:string = await toolCache.downloadTool(helmAllReleasesUrl);
try{ try{
const helmJSONArray = JSON.parse(fs.readFileSync(helmJSONPath, 'utf-8')) const helmJSON = JSON.parse(fs.readFileSync(helmJSONPath, 'utf-8'))
helmJSONArray.forEach(ver => { for(let i in helmJSON){
if(isValidVersion(ver["tag_name"])){ if(isValidVersion(helmJSON[i].tag_name)){
return ver; return helmJSON[i].tag_name;
} }
}); }
} catch(err){ } catch(err){
core.warning(util.format("Error while fetching the latest Helm release. Error: %s. Using default Helm version %s", err.toString(), stableHelmVersion)); core.warning(util.format("Error while fetching the latest Helm release. Error: %s. Using default Helm version %s", err.toString(), stableHelmVersion));
return stableHelmVersion; return stableHelmVersion;