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 fcc9cd6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 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 [ -n "${GITHUB_TOKEN}" ]; then
headers=(-H "Authorization: Bearer ${GITHUB_TOKEN}")
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,6 +50,9 @@ download_executable="${download_path}/tflint"

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

0 comments on commit fcc9cd6

Please sign in to comment.