mirror of
https://github.com/Azure/setup-kubectl.git
synced 2025-12-12 13:11:33 +00:00
Improved readability and maintainability
This commit is contained in:
parent
425b200956
commit
d6a2fb1310
1 changed files with 5 additions and 5 deletions
|
|
@ -29,7 +29,8 @@ export async function getLatestPatchVersion(
|
||||||
major: string,
|
major: string,
|
||||||
minor: string
|
minor: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const sourceURL = `https://cdn.dl.k8s.io/release/stable-${major}.${minor}.txt`
|
const version = `${major}.${minor}`
|
||||||
|
const sourceURL = `https://cdn.dl.k8s.io/release/stable-${version}.txt`
|
||||||
try {
|
try {
|
||||||
const downloadPath = await toolCache.downloadTool(sourceURL)
|
const downloadPath = await toolCache.downloadTool(sourceURL)
|
||||||
const latestPatch = fs
|
const latestPatch = fs
|
||||||
|
|
@ -37,17 +38,16 @@ export async function getLatestPatchVersion(
|
||||||
.toString()
|
.toString()
|
||||||
.trim()
|
.trim()
|
||||||
if (!latestPatch) {
|
if (!latestPatch) {
|
||||||
throw new Error(`No patch version found for ${major}.${minor}`)
|
throw new Error(`No patch version found for ${version}`)
|
||||||
}
|
}
|
||||||
return latestPatch
|
return latestPatch
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.debug(error)
|
core.debug(error)
|
||||||
core.warning('GetLatestPatchVersionFailed')
|
core.warning('GetLatestPatchVersionFailed')
|
||||||
throw new Error(
|
throw new Error(`Failed to get latest patch version for ${version}`)
|
||||||
`Failed to get latest patch version for ${major}.${minor}`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getExecutableExtension(): string {
|
export function getExecutableExtension(): string {
|
||||||
if (os.type().match(/^Win/)) {
|
if (os.type().match(/^Win/)) {
|
||||||
return '.exe'
|
return '.exe'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue