2022-06-28 00:31:07 +02:00
|
|
|
import * as os from 'os'
|
|
|
|
import * as util from 'util'
|
2022-01-05 17:19:30 +01:00
|
|
|
|
|
|
|
export function getKubectlArch(): string {
|
2022-06-28 00:31:07 +02:00
|
|
|
const arch = os.arch()
|
|
|
|
if (arch === 'x64') {
|
|
|
|
return 'amd64'
|
|
|
|
}
|
|
|
|
return arch
|
2022-01-05 17:19:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getkubectlDownloadURL(version: string, arch: string): string {
|
2022-06-28 00:31:07 +02:00
|
|
|
switch (os.type()) {
|
|
|
|
case 'Linux':
|
|
|
|
return util.format(
|
|
|
|
'https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/kubectl',
|
|
|
|
version,
|
|
|
|
arch
|
|
|
|
)
|
2022-01-05 17:19:30 +01:00
|
|
|
|
2022-06-28 00:31:07 +02:00
|
|
|
case 'Darwin':
|
|
|
|
return util.format(
|
|
|
|
'https://storage.googleapis.com/kubernetes-release/release/%s/bin/darwin/%s/kubectl',
|
|
|
|
version,
|
|
|
|
arch
|
|
|
|
)
|
2022-01-05 17:19:30 +01:00
|
|
|
|
2022-06-28 00:31:07 +02:00
|
|
|
case 'Windows_NT':
|
|
|
|
default:
|
|
|
|
return util.format(
|
|
|
|
'https://storage.googleapis.com/kubernetes-release/release/%s/bin/windows/%s/kubectl.exe',
|
|
|
|
version,
|
|
|
|
arch
|
|
|
|
)
|
|
|
|
}
|
2022-01-05 17:19:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getExecutableExtension(): string {
|
2022-06-28 00:31:07 +02:00
|
|
|
if (os.type().match(/^Win/)) {
|
|
|
|
return '.exe'
|
|
|
|
}
|
|
|
|
return ''
|
|
|
|
}
|