setup-kubectl/src/helpers.ts
Tommy Barnes a10d84bc2e
Refactoring Action for use with AKS Atlanta (#37)
* Did some reorganizing of code in run.ts, moved run.test.ts into /src, and put some helpers into helpers.ts in /src.

* Did some reorganizing of code in run.ts, moved run.test.ts into /src, and put some helpers into helpers.ts in /src.

* Grabbed the upstream integration tests and brought them here.  Removed bash script. Added validateKubectl.py to /test folder for integration tests.

* Ran npm run build

* Ran npm run build

* Updated on section for integration-tests.yml

* Removing ruby commands from integration tests yaml.

* Fixing discrepancies in integration test yaml.

* Fixing discrepancies in integration test yaml.

* Default to ubuntu-latest

* renamed python script according to workflow.

* renamed python script according to workflow.

* Fixing path parameters.

* Updated tsconfig.json

* Testing for int test failure.

* Validated that int tests work.

* Added new workflows.

* Testing release (#10)

* Did some reorganizing of code in run.ts, moved run.test.ts into /src, and put some helpers into helpers.ts in /src.

* Did some reorganizing of code in run.ts, moved run.test.ts into /src, and put some helpers into helpers.ts in /src.

* Grabbed the upstream integration tests and brought them here.  Removed bash script. Added validateKubectl.py to /test folder for integration tests.

* Ran npm run build

* Ran npm run build

* Updated on section for integration-tests.yml

* Removing ruby commands from integration tests yaml.

* Fixing discrepancies in integration test yaml.

* Fixing discrepancies in integration test yaml.

* Default to ubuntu-latest

* renamed python script according to workflow.

* renamed python script according to workflow.

* Fixing path parameters.

* Updated tsconfig.json

* Testing for int test failure.

* Validated that int tests work.

* Added new workflows.

Co-authored-by: Tommy Barnes <thbarnes@microsoft.com>

* made changes reflected in comments

Co-authored-by: Tommy Barnes <thbarnes@microsoft.com>
2022-01-05 11:19:30 -05:00

31 lines
No EOL
942 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): string {
switch (os.type()) {
case 'Linux':
return util.format('https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/kubectl', version, arch);
case 'Darwin':
return util.format('https://storage.googleapis.com/kubernetes-release/release/%s/bin/darwin/%s/kubectl', version, arch);
case 'Windows_NT':
default:
return util.format('https://storage.googleapis.com/kubernetes-release/release/%s/bin/windows/%s/kubectl.exe', version, arch);
}
}
export function getExecutableExtension(): string {
if (os.type().match(/^Win/)) {
return '.exe';
}
return '';
}