review comments fix

This commit is contained in:
Raghavendra S
2020-05-13 09:00:19 +05:30
parent 5801d81e70
commit d56b96d256
2 changed files with 22 additions and 24 deletions

View File

@ -1,12 +1,12 @@
# Setup Helm # Setup Helm
#### Install a specific version of helm binary on the runner. #### Install a specific version of helm binary on the runner.
Acceptable values are latest or any semantic version string like 1.15.0. Use this action in workflow to define which version of helm will be used. Acceptable values are latest or any semantic version string like v2.16.7 Use this action in workflow to define which version of helm will be used.
```yaml ```yaml
- uses: azure/setup-helm@v1 - uses: azure/setup-helm@v1
with: with:
version: v'<version>' # default is latest stable version: '<version>' # default is latest stable
id: install id: install
``` ```

View File

@ -11,7 +11,7 @@ import * as core from '@actions/core';
const helmToolName = 'helm'; const helmToolName = 'helm';
const stableHelmVersion = 'v2.14.1'; const stableHelmVersion = 'v2.14.1';
const helmLatestReleaseUrl = 'https://api.github.com/repos/helm/helm/releases/latest'; const helmLatestReleaseUrl = 'https://api.github.com/repos/helm/helm/releases/latest';
function getExecutableExtension(): string { function getExecutableExtension(): string {
if (os.type().match(/^Win/)) { if (os.type().match(/^Win/)) {
@ -37,11 +37,10 @@ function getHelmDownloadURL(version: string): string {
async function getStableHelmVersion(): Promise<string> { async function getStableHelmVersion(): Promise<string> {
return toolCache.downloadTool(helmLatestReleaseUrl).then((downloadPath) => { return toolCache.downloadTool(helmLatestReleaseUrl).then((downloadPath) => {
const response = JSON.parse(fs.readFileSync(downloadPath, 'utf8').toString().trim()); const response = JSON.parse(fs.readFileSync(downloadPath, 'utf8').toString().trim());
if (!response.tag_name) if (!response.tag_name) {
{
return stableHelmVersion; return stableHelmVersion;
} }
return response.tag_name; return response.tag_name;
}, (error) => { }, (error) => {
core.debug(error); core.debug(error);
@ -51,24 +50,23 @@ async function getStableHelmVersion(): Promise<string> {
} }
var walkSync = function(dir, filelist, fileToFind) { var walkSync = function (dir, filelist, fileToFind) {
var files = fs.readdirSync(dir); var files = fs.readdirSync(dir);
filelist = filelist || []; filelist = filelist || [];
files.forEach(function(file) { files.forEach(function (file) {
if (fs.statSync(path.join(dir, file)).isDirectory()) { if (fs.statSync(path.join(dir, file)).isDirectory()) {
filelist = walkSync(path.join(dir, file), filelist, fileToFind); filelist = walkSync(path.join(dir, file), filelist, fileToFind);
} }
else { else {
core.debug(file); core.debug(file);
if(file == fileToFind) if (file == fileToFind) {
{ filelist.push(path.join(dir, file));
filelist.push(path.join(dir, file)); }
} }
}
}); });
return filelist; return filelist;
}; };
async function downloadHelm(version: string): Promise<string> { async function downloadHelm(version: string): Promise<string> {
if (!version) { version = await getStableHelmVersion(); } if (!version) { version = await getStableHelmVersion(); }
let cachedToolpath = toolCache.find(helmToolName, version); let cachedToolpath = toolCache.find(helmToolName, version);
@ -89,7 +87,7 @@ async function downloadHelm(version: string): Promise<string> {
if (!helmpath) { if (!helmpath) {
throw new Error(util.format("Helm executable not found in path ", cachedToolpath)); throw new Error(util.format("Helm executable not found in path ", cachedToolpath));
} }
fs.chmodSync(helmpath, '777'); fs.chmodSync(helmpath, '777');
return helmpath; return helmpath;
} }
@ -110,14 +108,14 @@ async function run() {
let version = core.getInput('version', { 'required': true }); let version = core.getInput('version', { 'required': true });
if (version.toLocaleLowerCase() === 'latest') { if (version.toLocaleLowerCase() === 'latest') {
version = await getStableHelmVersion(); version = await getStableHelmVersion();
}else if(!version.toLocaleLowerCase().startsWith('v')){ } else if (!version.toLocaleLowerCase().startsWith('v')) {
version = 'v' + version; version = 'v' + version;
} }
let cachedPath = await downloadHelm(version); let cachedPath = await downloadHelm(version);
try { try {
if (!process.env['PATH'].startsWith(path.dirname(cachedPath))) { if (!process.env['PATH'].startsWith(path.dirname(cachedPath))) {
core.addPath(path.dirname(cachedPath)); core.addPath(path.dirname(cachedPath));
} }