Skip to content

Commit

Permalink
Stop using the GitHub API in the install script (#224)
Browse files Browse the repository at this point in the history
The install script provides a strange error when the GitHub API rate
limit is encountered. This commit removes the need to use the GitHub
API and bypasses rate limiting checks.

Signed-off-by: mprahl <[email protected]>
  • Loading branch information
mprahl authored May 6, 2022
1 parent 916b176 commit c55e8ca
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,6 @@ checkExisting() {
fi
}

getLatestRelease() {
local releaseUrl="https://api.github.com/repos/${GITHUB_ORG}/${GITHUB_REPO}/releases"
local latest_release=""

if [ "$HTTP_REQUEST_CLI" == "curl" ]; then
latest_release=$(curl -s $releaseUrl | grep \"tag_name\" | grep -v rc | awk 'NR==1{print $2}' | sed -n 's/\"\(.*\)\",/\1/p')
else
latest_release=$(wget -q --header="Accept: application/json" -O - $releaseUrl | grep \"tag_name\" | grep -v rc | awk 'NR==1{print $2}' | sed -n 's/\"\(.*\)\",/\1/p')
fi

ret_val=$latest_release
}

runAsRoot() {
local CMD="$*"

Expand All @@ -94,11 +81,15 @@ runAsRoot() {
}

downloadFile() {
LATEST_RELEASE_TAG=$1

TARGET_VERSION=$1
DOWNLOAD_BASE="https://github.com/${GITHUB_ORG}/${GITHUB_REPO}"
CLI_ARTIFACT="${CLI_FILENAME}_${OS}_${ARCH}.tar.gz"
DOWNLOAD_BASE="https://github.com/${GITHUB_ORG}/${GITHUB_REPO}/releases/download"
DOWNLOAD_URL="${DOWNLOAD_BASE}/${LATEST_RELEASE_TAG}/${CLI_ARTIFACT}"

if [ "$TARGET_VERSION" == "latest" ]; then
DOWNLOAD_URL="${DOWNLOAD_BASE}/releases/latest/download/${CLI_ARTIFACT}"
else
DOWNLOAD_URL="${DOWNLOAD_BASE}/releases/download/${TARGET_VERSION}/${CLI_ARTIFACT}"
fi

# Create the temp directory
TMP_ROOT=$(mktemp -dt clusteradm-install-XXXXXX)
Expand Down Expand Up @@ -188,18 +179,17 @@ getSystemInfo
checkHttpRequestCLI

if [ -z "$1" ]; then
echo "Getting the latest clusteradm CLI..."
getLatestRelease
TARGET_VERSION="latest"
else
ret_val=v$1
TARGET_VERSION=v$1
fi

verifySupported $ret_val
verifySupported
checkExisting

echo "Installing $ret_val OCM clusteradm CLI..."
echo "Installing $TARGET_VERSION OCM clusteradm CLI..."

downloadFile $ret_val
downloadFile $TARGET_VERSION
installFile
cleanup

Expand Down

0 comments on commit c55e8ca

Please sign in to comment.