Skip to content

Commit

Permalink
Allow passing GITHUB_TOKEN to install script
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 committed Dec 25, 2022
1 parent ec6c4ef commit 00a3faf
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions install_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ echo "os=$os"
echo -e "\n\n===================================================="

get_latest_release() {
curl --fail -sS "https://api.github.com/repos/terraform-linters/tflint/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
headers=()
if [ $1 != "" ]; then
headers=(-H "Authorization: Bearer $1")
fi
curl --fail -sS "${headers[@]}" "https://api.github.com/repos/terraform-linters/tflint/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}

download_path=$(mktemp -d -t tflint.XXXXXXXXXX)
Expand All @@ -46,7 +50,12 @@ download_executable="${download_path}/tflint"

if [ -z "${TFLINT_VERSION}" ] || [ "${TFLINT_VERSION}" == "latest" ]; then
echo "Looking up the latest version ..."
version=$(get_latest_release)
token=""
if [ -n "${GITHUB_TOKEN}" ]; then
token=${GITHUB_TOKEN}
echo "Requesting with GITHUB_TOKEN ..."
fi
version=$(get_latest_release $token)
else
version=${TFLINT_VERSION}
fi
Expand Down

0 comments on commit 00a3faf

Please sign in to comment.