From f8f8c9350953fc343a352ed78c41432aac70281f Mon Sep 17 00:00:00 2001 From: Shohei Maeda <11495867+smaeda-ks@users.noreply.github.com> Date: Mon, 23 May 2022 22:47:07 +0900 Subject: [PATCH] [Ubuntu] Use new Hashicorp Releases API (#5587) --- images/linux/scripts/installers/packer.sh | 11 +++++++---- images/linux/scripts/installers/terraform.sh | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/images/linux/scripts/installers/packer.sh b/images/linux/scripts/installers/packer.sh index 1a15ee4c..34c7f01e 100644 --- a/images/linux/scripts/installers/packer.sh +++ b/images/linux/scripts/installers/packer.sh @@ -4,10 +4,13 @@ ## Desc: Installs packer ################################################################################ +source $HELPER_SCRIPTS/install.sh + # Install Packer -PACKER_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packer | jq -r .current_version) -curl -LO "https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip" -unzip -qq "packer_${PACKER_VERSION}_linux_amd64.zip" -d /usr/local/bin -rm -f "packer_${PACKER_VERSION}_linux_amd64.zip" +URL=$(curl -s https://api.releases.hashicorp.com/v1/releases/packer/latest | jq -r '.builds[] | select((.arch=="amd64") and (.os=="linux")).url') +ZIP_NAME="packer_linux_amd64.zip" +download_with_retries "${URL}" "/tmp" "${ZIP_NAME}" +unzip -qq "/tmp/${ZIP_NAME}" -d /usr/local/bin +rm -f "/tmp/${ZIP_NAME}" invoke_tests "Tools" "Packer" \ No newline at end of file diff --git a/images/linux/scripts/installers/terraform.sh b/images/linux/scripts/installers/terraform.sh index d2b621ae..bed616fb 100644 --- a/images/linux/scripts/installers/terraform.sh +++ b/images/linux/scripts/installers/terraform.sh @@ -4,10 +4,13 @@ ## Desc: Installs terraform ################################################################################ +source $HELPER_SCRIPTS/install.sh + # Install Terraform -TERRAFORM_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r .current_version) -curl -LO "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" -unzip -qq "terraform_${TERRAFORM_VERSION}_linux_amd64.zip" -d /usr/local/bin -rm -f "terraform_${TERRAFORM_VERSION}_linux_amd64.zip" +URL=$(curl -s https://api.releases.hashicorp.com/v1/releases/terraform/latest | jq -r '.builds[] | select((.arch=="amd64") and (.os=="linux")).url') +ZIP_NAME="terraform_linux_amd64.zip" +download_with_retries "${URL}" "/tmp" "${ZIP_NAME}" +unzip -qq "/tmp/${ZIP_NAME}" -d /usr/local/bin +rm -f "/tmp/${ZIP_NAME}" invoke_tests "Tools" "Terraform" \ No newline at end of file