Skip to content

Commit

Permalink
fix: install script (#4230)
Browse files Browse the repository at this point in the history
* fix: install script
  • Loading branch information
edouard-lopez authored Aug 2, 2023
1 parent 699e66c commit 62661af
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
echo "Getting kubectl-testkube plugin"
#!/bin/sh

if [ ! -z "${DEBUG}" ];
then set -x
Expand Down Expand Up @@ -31,27 +31,42 @@ _detect_os(){
}

_download_url() {
local arch="$(_detect_arch)"
local os="$(_detect_os)"
local arch
local os
local tag
local version

arch="$(_detect_arch)"
os="$(_detect_os)"
if [ -z "$TESTKUBE_VERSION" ]; then
if [ "$1" = "beta" ]; then
local version=$(curl -s "https://api.github.com/repos/kubeshop/testkube/releases" 2>/dev/null | jq -r '.[].tag_name | select(test("beta"))' | head -n 1)
tag="$(
curl -s "https://api.github.com/repos/kubeshop/testkube/releases" \
2>/dev/null \
| jq -r '.[].tag_name | select(test("beta"))' \
| head -n 1 \
)"
else
local version=$(curl -s "https://api.github.com/repos/kubeshop/testkube/releases/latest" 2>/dev/null | jq -r '.tag_name')
tag="$(
curl -s "https://api.github.com/repos/kubeshop/testkube/releases/latest" \
2>/dev/null \
| jq -r '.tag_name' \
)"
fi
else
local version="$TESTKUBE_VERSION"
tag="$TESTKUBE_VERSION"
fi
version="${tag/#v/}" # remove leading v if present

echo "https://github.com/kubeshop/testkube/releases/download/${version}/testkube_${version:1}_${os}_$arch.tar.gz"
echo "https://github.com/kubeshop/testkube/releases/download/${tag}/testkube_${version:-1}_${os}_$arch.tar.gz"
}

if [ "$1" = "beta" ]; then
echo "Downloading testkube from URL: $(_download_url "beta")"
curl -sSLf $(_download_url "beta") > testkube.tar.gz
curl -sSLf "$(_download_url "beta")" > testkube.tar.gz
else
echo "Downloading testkube from URL: $(_download_url)"
curl -sSLf $(_download_url) > testkube.tar.gz
curl -sSLf "$(_download_url)" > testkube.tar.gz
fi

tar -xzf testkube.tar.gz kubectl-testkube
Expand Down

0 comments on commit 62661af

Please sign in to comment.