diff --git a/action.yml b/action.yml index 852cec0..1e86a0e 100644 --- a/action.yml +++ b/action.yml @@ -5,6 +5,10 @@ inputs: description: 'Version of kubectl' required: true default: 'latest' + url: + description: 'Url of kubectl' + required: false + default: '' outputs: kubectl-path: description: 'Path to the cached kubectl binary' diff --git a/src/helpers.ts b/src/helpers.ts index a0838f6..9cb9c59 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -9,7 +9,10 @@ export function getKubectlArch(): string { return arch } -export function getkubectlDownloadURL(version: string, arch: string): string { +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` diff --git a/src/run.ts b/src/run.ts index 53c1994..24fae97 100644 --- a/src/run.ts +++ b/src/run.ts @@ -18,10 +18,11 @@ const stableVersionUrl = export async function run() { let version = core.getInput('version', {required: true}) + let toolurl = core.getInput('url', {required: false}) if (version.toLocaleLowerCase() === 'latest') { version = await getStableKubectlVersion() } - const cachedPath = await downloadKubectl(version) + const cachedPath = await downloadKubectl(version, toolurl) core.addPath(path.dirname(cachedPath)) @@ -48,14 +49,14 @@ export async function getStableKubectlVersion(): Promise { ) } -export async function downloadKubectl(version: string): Promise { +export async function downloadKubectl(version: string, toolurl: string = ''): Promise { let cachedToolpath = toolCache.find(kubectlToolName, version) let kubectlDownloadPath = '' const arch = getKubectlArch() if (!cachedToolpath) { try { kubectlDownloadPath = await toolCache.downloadTool( - getkubectlDownloadURL(version, arch) + getkubectlDownloadURL(version, arch, toolurl) ) } catch (exception) { if (