Improved readability and maintainability

This commit is contained in:
Ogheneobukome Ejaife 2025-07-08 13:14:56 -04:00
parent 425b200956
commit d6a2fb1310
No known key found for this signature in database
GPG key ID: F29F0EA1A151DA11

View file

@ -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'