mirror of
https://github.com/Azure/setup-helm.git
synced 2025-11-08 05:26:56 +00:00
Pushing recent changes before computer reset
This commit is contained in:
parent
b34dae9d36
commit
363e4253a0
3 changed files with 25 additions and 13 deletions
|
|
@ -22,28 +22,36 @@ describe('run.ts', () => {
|
||||||
|
|
||||||
test('getHelmDownloadURL() - return the URL to download helm for Linux', () => {
|
test('getHelmDownloadURL() - return the URL to download helm for Linux', () => {
|
||||||
jest.spyOn(os, 'type').mockReturnValue('Linux');
|
jest.spyOn(os, 'type').mockReturnValue('Linux');
|
||||||
const kubectlLinuxUrl = 'https://get.helm.sh/helm-v3.2.1-linux-amd64.zip'
|
const kubectlLinuxUrl = 'https://get.helm.sh/helm-v3.7.2-linux-amd64.zip'
|
||||||
|
|
||||||
expect(run.getHelmDownloadURL('v3.2.1')).toBe(kubectlLinuxUrl);
|
expect(run.getHelmDownloadURL('v3.7.2')).toBe(kubectlLinuxUrl);
|
||||||
expect(os.type).toBeCalled();
|
expect(os.type).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getHelmDownloadURL() - return the URL to download helm for Darwin', () => {
|
test('getHelmDownloadURL() - return the URL to download helm for Darwin', () => {
|
||||||
jest.spyOn(os, 'type').mockReturnValue('Darwin');
|
jest.spyOn(os, 'type').mockReturnValue('Darwin');
|
||||||
const kubectlDarwinUrl = 'https://get.helm.sh/helm-v3.2.1-darwin-amd64.zip'
|
const kubectlDarwinUrl = 'https://get.helm.sh/helm-v3.7.2-darwin-amd64.zip'
|
||||||
|
|
||||||
expect(run.getHelmDownloadURL('v3.2.1')).toBe(kubectlDarwinUrl);
|
expect(run.getHelmDownloadURL('v3.7.2')).toBe(kubectlDarwinUrl);
|
||||||
expect(os.type).toBeCalled();
|
expect(os.type).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
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');
|
||||||
|
|
||||||
const kubectlWindowsUrl = 'https://get.helm.sh/helm-v3.2.1-windows-amd64.zip'
|
const kubectlWindowsUrl = 'https://get.helm.sh/helm-v3.7.2-windows-amd64.zip'
|
||||||
expect(run.getHelmDownloadURL('v3.2.1')).toBe(kubectlWindowsUrl);
|
expect(run.getHelmDownloadURL('v3.7.2')).toBe(kubectlWindowsUrl);
|
||||||
expect(os.type).toBeCalled();
|
expect(os.type).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('getLatestHelmVersion() - return the latest version of HELM', async () => {
|
||||||
|
try{
|
||||||
|
expect(run.getLatestHelmVersion()).toBe("v3.7.2");
|
||||||
|
} catch (e){
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('getStableHelmVersion() - download stable version file, read version and return it', async () => {
|
test('getStableHelmVersion() - download stable version file, read version and return it', async () => {
|
||||||
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool');
|
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool');
|
||||||
const response = JSON.stringify(
|
const response = JSON.stringify(
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.run = exports.findHelm = exports.downloadHelm = exports.walkSync = exports.getStableHelmVersion = exports.getHelmDownloadURL = exports.getExecutableExtension = void 0;
|
exports.run = exports.findHelm = exports.getLatestHelmVersion = exports.downloadHelm = exports.walkSync = exports.getStableHelmVersion = exports.getHelmDownloadURL = exports.getExecutableExtension = void 0;
|
||||||
const os = require("os");
|
const os = require("os");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const util = require("util");
|
const util = require("util");
|
||||||
|
|
@ -116,7 +116,8 @@ exports.downloadHelm = downloadHelm;
|
||||||
// getLatestHelmVersion uses cURL and regex to scrape the latest version
|
// getLatestHelmVersion uses cURL and regex to scrape the latest version
|
||||||
function getLatestHelmVersion() {
|
function getLatestHelmVersion() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
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/".*//'`;
|
console.log("Test");
|
||||||
|
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/".*//'`;
|
||||||
let latestHelm = "";
|
let latestHelm = "";
|
||||||
let latestHelmErr = "";
|
let latestHelmErr = "";
|
||||||
const options = {};
|
const options = {};
|
||||||
|
|
@ -129,11 +130,13 @@ function getLatestHelmVersion() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
yield exec.exec(command, [], options);
|
yield exec.exec(command, [], options);
|
||||||
if (latestHelmErr !== "" || isValidVersion(latestHelm))
|
console.log("latestHelm");
|
||||||
|
if (latestHelmErr !== "" || !isValidVersion(latestHelm))
|
||||||
return getStableHelmVersion();
|
return getStableHelmVersion();
|
||||||
return latestHelm;
|
return latestHelm;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
exports.getLatestHelmVersion = getLatestHelmVersion;
|
||||||
// isValidVersion checks if verison matches the specified type and is a stable release
|
// isValidVersion checks if verison matches the specified type and is a stable release
|
||||||
function isValidVersion(version) {
|
function isValidVersion(version) {
|
||||||
return version.indexOf('rc') == -1;
|
return version.indexOf('rc') == -1;
|
||||||
|
|
|
||||||
|
|
@ -106,8 +106,9 @@ export async function downloadHelm(version: string): Promise<string> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// getLatestHelmVersion uses cURL and regex to scrape the latest version
|
// getLatestHelmVersion uses cURL and regex to scrape the latest version
|
||||||
async function getLatestHelmVersion(): Promise<string>{
|
export async function getLatestHelmVersion(): Promise<string>{
|
||||||
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/".*//'`;
|
console.log("Test");
|
||||||
|
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/".*//'`;
|
||||||
let latestHelm: string = "";
|
let latestHelm: string = "";
|
||||||
let latestHelmErr: string = "";
|
let latestHelmErr: string = "";
|
||||||
|
|
||||||
|
|
@ -123,8 +124,8 @@ async function getLatestHelmVersion(): Promise<string>{
|
||||||
};
|
};
|
||||||
|
|
||||||
await exec.exec(command, [], options);
|
await exec.exec(command, [], options);
|
||||||
|
console.log("latestHelm")
|
||||||
if(latestHelmErr !== "" || isValidVersion(latestHelm)) return getStableHelmVersion();
|
if(latestHelmErr !== "" || !isValidVersion(latestHelm)) return getStableHelmVersion();
|
||||||
return latestHelm;
|
return latestHelm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue