4
0
Fork 0
mirror of https://github.com/Azure/setup-helm.git synced 2025-11-07 21:16:57 +00:00
This commit is contained in:
Oliver King 2022-07-08 11:38:28 -04:00
parent 42a468462c
commit 30ffb39edf

View file

@ -18,14 +18,15 @@ export async function run() {
let version = core.getInput('version', {required: true}) let version = core.getInput('version', {required: true})
if (version !== 'latest' && version[0] !== 'v') { if (version !== 'latest' && version[0] !== 'v') {
core.info('Getting latest Helm version')
version = getValidVersion(version) version = getValidVersion(version)
} }
if (version.toLocaleLowerCase() === 'latest') { if (version.toLocaleLowerCase() === 'latest') {
version = await getLatestHelmVersion() version = await getLatestHelmVersion()
} }
core.debug(util.format('Downloading %s', version)) core.info(`Downloading ${version}`)
let cachedPath = await downloadHelm(version) const cachedPath = await downloadHelm(version)
try { try {
if (!process.env['PATH'].startsWith(path.dirname(cachedPath))) { if (!process.env['PATH'].startsWith(path.dirname(cachedPath))) {
@ -35,13 +36,11 @@ export async function run() {
//do nothing, set as output variable //do nothing, set as output variable
} }
console.log( core.info(`Helm tool version '${version}' has been cached at ${cachedPath}`)
`Helm tool version: '${version}' has been cached at ${cachedPath}`
)
core.setOutput('helm-path', cachedPath) core.setOutput('helm-path', cachedPath)
} }
//Returns version with proper v before it // Prefixes version with v
export function getValidVersion(version: string): string { export function getValidVersion(version: string): string {
return 'v' + version return 'v' + version
} }
@ -74,7 +73,7 @@ export async function getLatestHelmVersion(): Promise<string> {
return stableHelmVersion return stableHelmVersion
} }
core.debug( core.warning(
`Could not find valid release. Using default version ${stableHelmVersion}` `Could not find valid release. Using default version ${stableHelmVersion}`
) )
return stableHelmVersion return stableHelmVersion
@ -142,10 +141,9 @@ export async function downloadHelm(version: string): Promise<string> {
) )
} catch (exception) { } catch (exception) {
throw new Error( throw new Error(
util.format( `Failed to download Helm from location ${getHelmDownloadURL(
'Failed to download Helm from location', version
getHelmDownloadURL(version) )}`
)
) )
} }