add tool custom url
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
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
This commit is contained in:
parent
a76651a0e0
commit
6563d5d80a
@ -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'
|
||||
|
||||
@ -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`
|
||||
|
||||
@ -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<string> {
|
||||
)
|
||||
}
|
||||
|
||||
export async function downloadKubectl(version: string): Promise<string> {
|
||||
export async function downloadKubectl(version: string, toolurl: string = ''): Promise<string> {
|
||||
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 (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user