Skip to content

Commit

Permalink
Add support for a binaries_url parameter (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajbos authored Nov 28, 2022
1 parent bd911c0 commit f9c5b73
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ runs:
- ${{ inputs.version }}
- ${{ inputs.config }}
- ${{ inputs.command }}
- ${{ inputs.binaries-url }}
branding:
icon: 'terminal'
color: 'blue'
Expand All @@ -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
17 changes: 12 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f9c5b73

Please sign in to comment.