From f9c5b732c3c07c46f305611b8a4e635f49239bc3 Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Mon, 28 Nov 2022 15:44:22 +0100 Subject: [PATCH] Add support for a binaries_url parameter (#22) --- README.md | 3 +++ action.yml | 4 ++++ entrypoint.sh | 17 ++++++++++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f5fc199..ec6743f 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ jobs: with: config: ${{ secrets.KUBE_CONFIG_DATA }} version: v1.21.0 # specify kubectl binary version explicitly + binaries-url: "https://dl.k8s.io/release/v1.21.0/bin/linux/amd64/kubectl" # specify the download url explicitly command: rollout status deployment/my-app ``` @@ -44,4 +45,6 @@ cat $HOME/.kube/config | base64 `version`: The kubectl version with a 'v' prefix, e.g. `v1.21.0`. It defaults to the latest kubectl binary version available. +`binaries-url`: The url to download the binaries from. It defaults to the official release page if empty. + **Note**: Do not use kubectl config view as this will hide the certificate-authority-data. diff --git a/action.yml b/action.yml index 4c80cb4..573f3e7 100644 --- a/action.yml +++ b/action.yml @@ -7,6 +7,7 @@ runs: - ${{ inputs.version }} - ${{ inputs.config }} - ${{ inputs.command }} + - ${{ inputs.binaries-url }} branding: icon: 'terminal' color: 'blue' @@ -21,3 +22,6 @@ inputs: command: description: 'kubectl command to run, without the kubectl, e.g. `get pods`' required: true + binaries-url: + description: 'Url to download the binaries from, defaults to the official dl.k8s.io url' + required: false diff --git a/entrypoint.sh b/entrypoint.sh index fb9a94d..766621c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,14 +5,21 @@ set -e version="$1" config="$2" command="$3" +binaries_url="$4" -if [ "$version" = "latest" ]; then - version=$(curl -Ls https://dl.k8s.io/release/stable.txt) -fi +if [ -n "$binaries_url" ]; then + if [ "$version" = "latest" ]; then + version=$(curl -Ls https://dl.k8s.io/release/stable.txt) + fi + + echo "using kubectl@$version" -echo "using kubectl@$version" + curl -sLO "https://dl.k8s.io/release/$version/bin/linux/amd64/kubectl" -o kubectl +else + echo "downloading kubectl binaries from $binaries_url" + curl -sLO $binaries_url -o kubectl +fi -curl -sLO "https://dl.k8s.io/release/$version/bin/linux/amd64/kubectl" -o kubectl chmod +x kubectl mv kubectl /usr/local/bin