setup-kubectl-cn/src/helpers.ts
suisrc 6563d5d80a
Some checks failed
Run unit tests. / build (push) Has been cancelled
Run prettify / Prettier Check (push) Has been cancelled
Integration test for setup-kubectl / Validate release and master branch (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
add tool custom url
2025-05-15 10:40:34 +08:00

35 lines
878 B
TypeScript

import * as os from 'os'
import * as util from 'util'
export function getKubectlArch(): string {
const arch = os.arch()
if (arch === 'x64') {
return 'amd64'
}
return arch
}
export function getkubectlDownloadURL(version: string, arch: string, url: string = ''): string {
if (url != '') {
return url.replace('${version}', version).replace('${arch}', arch)
}
switch (os.type()) {
case 'Linux':
return `https://dl.k8s.io/release/${version}/bin/linux/${arch}/kubectl`
case 'Darwin':
return `https://dl.k8s.io/release/${version}/bin/darwin/${arch}/kubectl`
case 'Windows_NT':
default:
return `https://dl.k8s.io/release/${version}/bin/windows/${arch}/kubectl.exe`
}
}
export function getExecutableExtension(): string {
if (os.type().match(/^Win/)) {
return '.exe'
}
return ''
}