mirror of
https://github.com/Azure/setup-helm.git
synced 2025-11-07 21:16:57 +00:00
Added version validation check
This commit is contained in:
parent
2998c83e16
commit
b3efc63e7e
2 changed files with 12 additions and 0 deletions
|
|
@ -60,6 +60,10 @@ describe("run.ts", () => {
|
||||||
expect(os.arch).toBeCalled();
|
expect(os.arch).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("getValidVersion() - return version with v prepended", () => {
|
||||||
|
expect(run.getValidVersion("3.8.0")).toBe("v3.8.0");
|
||||||
|
});
|
||||||
|
|
||||||
test("getHelmDownloadURL() - return the URL to download helm for Windows", () => {
|
test("getHelmDownloadURL() - return the URL to download helm for Windows", () => {
|
||||||
jest.spyOn(os, "type").mockReturnValue("Windows_NT");
|
jest.spyOn(os, "type").mockReturnValue("Windows_NT");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,9 @@ const helmAllReleasesUrl = "https://api.github.com/repos/helm/helm/releases";
|
||||||
export async function run() {
|
export async function run() {
|
||||||
let version = core.getInput("version", { required: true });
|
let version = core.getInput("version", { required: true });
|
||||||
|
|
||||||
|
if(version[0] !== "v"){
|
||||||
|
version = getValidVersion(version);
|
||||||
|
}
|
||||||
if (version.toLocaleLowerCase() === "latest") {
|
if (version.toLocaleLowerCase() === "latest") {
|
||||||
version = await getLatestHelmVersion();
|
version = await getLatestHelmVersion();
|
||||||
}
|
}
|
||||||
|
|
@ -38,6 +41,11 @@ export async function run() {
|
||||||
core.setOutput("helm-path", cachedPath);
|
core.setOutput("helm-path", cachedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Returns version with proper v before it
|
||||||
|
export function getValidVersion(version:string): string {
|
||||||
|
return "v" + version;
|
||||||
|
}
|
||||||
|
|
||||||
// Downloads the helm releases JSON and parses all the recent versions of helm from it.
|
// Downloads the helm releases JSON and parses all the recent versions of helm from it.
|
||||||
// Defaults to sending stable helm version if none are valid or if it fails
|
// Defaults to sending stable helm version if none are valid or if it fails
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue