mirror of
https://github.com/Azure/setup-helm.git
synced 2025-11-07 21:16:57 +00:00
Added comment on getLatestHelmVersion and variable for helm release url to command
This commit is contained in:
parent
e468b13d6c
commit
b34dae9d36
2 changed files with 8 additions and 10 deletions
|
|
@ -113,9 +113,10 @@ function downloadHelm(version) {
|
|||
});
|
||||
}
|
||||
exports.downloadHelm = downloadHelm;
|
||||
// getLatestHelmVersion uses cURL and regex to scrape the latest version
|
||||
function getLatestHelmVersion() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const command = `curl -Ls https://api.github.com/repos/helm/helm/releases | grep 'v3.[0-9]*.[0-9]*' | sed -E 's/ .*\/helm\/helm\/releases\/tag\/tag\/(v[0-9\.]+)".*/\\1/g' | head -1 | sed -E 's/.*tag\///' | sed -E 's/".*//'`;
|
||||
const command = `curl -Ls ${helmAllReleasesUrl} | grep 'v3.[0-9]*.[0-9]*' | sed -E 's/ .*\/helm\/helm\/releases\/tag\/tag\/(v[0-9\.]+)".*/\\1/g' | head -1 | sed -E 's/.*tag\///' | sed -E 's/".*//'`;
|
||||
let latestHelm = "";
|
||||
let latestHelmErr = "";
|
||||
const options = {};
|
||||
|
|
@ -128,15 +129,13 @@ function getLatestHelmVersion() {
|
|||
}
|
||||
};
|
||||
yield exec.exec(command, [], options);
|
||||
if (latestHelmErr !== "")
|
||||
if (latestHelmErr !== "" || isValidVersion(latestHelm))
|
||||
return getStableHelmVersion();
|
||||
return latestHelm;
|
||||
});
|
||||
}
|
||||
// isValidVersion checks if verison matches the specified type and is a stable release
|
||||
function isValidVersion(version, type) {
|
||||
if (!version.toLocaleLowerCase().startsWith(type))
|
||||
return false;
|
||||
function isValidVersion(version) {
|
||||
return version.indexOf('rc') == -1;
|
||||
}
|
||||
function findHelm(rootFolder) {
|
||||
|
|
|
|||
|
|
@ -105,8 +105,9 @@ export async function downloadHelm(version: string): Promise<string> {
|
|||
return helmpath;
|
||||
}
|
||||
|
||||
// getLatestHelmVersion uses cURL and regex to scrape the latest version
|
||||
async function getLatestHelmVersion(): Promise<string>{
|
||||
const command:string = `curl -Ls https://api.github.com/repos/helm/helm/releases | grep 'v3.[0-9]*.[0-9]*' | sed -E 's/ .*\/helm\/helm\/releases\/tag\/tag\/(v[0-9\.]+)".*/\\1/g' | head -1 | sed -E 's/.*tag\///' | sed -E 's/".*//'`;
|
||||
const command:string = `curl -Ls ${helmAllReleasesUrl} | grep 'v3.[0-9]*.[0-9]*' | sed -E 's/ .*\/helm\/helm\/releases\/tag\/tag\/(v[0-9\.]+)".*/\\1/g' | head -1 | sed -E 's/.*tag\///' | sed -E 's/".*//'`;
|
||||
let latestHelm: string = "";
|
||||
let latestHelmErr: string = "";
|
||||
|
||||
|
|
@ -123,14 +124,12 @@ async function getLatestHelmVersion(): Promise<string>{
|
|||
|
||||
await exec.exec(command, [], options);
|
||||
|
||||
if(latestHelmErr !== "") return getStableHelmVersion();
|
||||
if(latestHelmErr !== "" || isValidVersion(latestHelm)) return getStableHelmVersion();
|
||||
return latestHelm;
|
||||
}
|
||||
|
||||
// isValidVersion checks if verison matches the specified type and is a stable release
|
||||
function isValidVersion(version: string, type: string): boolean {
|
||||
if (!version.toLocaleLowerCase().startsWith(type))
|
||||
return false;
|
||||
function isValidVersion(version: string): boolean {
|
||||
return version.indexOf('rc') == -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue