Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ install & manage versions.
- ASDF_HASHICORP_OVERWRITE_ARCH: force the plugin to use a specified processor architecture rather than the automatically detected value. Useful, for example, for allowing users on M1 Macs to install `amd64` binaries when there's no `arm64` binary available.
- ASDF_HASHICORP_OVERWRITE_ARCH_<specific tool>: like the previous override, but for each specific tool, e.g. ASDF_HASHICORP_OVERWRITE_ARCH_TERRAFORM. Works with ASDF_HASHICORP_OVERWRITE_ARCH, and tool-specific overrides take precedence.
- ASDF_HASHICORP_TERRAFORM_VERSION_FILE: Which `.tf`-file to examine for version constraints when using the `legacy_version_file` option in `~/.asdfrc`. Defaults to `main.tf`
- ASDF_HASHICORP_RELEASES_HOST: Specify a different host to get the binaries from. (Default is https://releases.hashicorp.com)

## License

Expand Down
7 changes: 4 additions & 3 deletions bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ get_gpg_filename() {
}

get_download_url() {
releases_host=${ASDF_HASHICORP_RELEASES_HOST:-"https://releases.hashicorp.com"}

local -r version="$1"
local -r type="$2"
local -r keyid="${3-}"
Expand All @@ -170,12 +172,11 @@ get_download_url() {
exit 1
;;
esac
local -r releases_host="https://releases.hashicorp.com"

if ! curl --fail --silent --head "${releases_host}/${toolname}/${version}/${filename}" >/dev/null && [[ ${filename} == *"arm64"* ]]; then
echo "https://releases.hashicorp.com/${toolname}/${version}/${filename//arm64/arm}"
echo "${releases_host}/${toolname}/${version}/${filename//arm64/arm}"
else
echo "https://releases.hashicorp.com/${toolname}/${version}/${filename}"
echo "${releases_host}/${toolname}/${version}/${filename}"
fi
}

Expand Down
4 changes: 3 additions & 1 deletion bin/list-all
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ readonly __dirname
readonly toolname

list_all() {
releases_host=${ASDF_HASHICORP_RELEASES_HOST:-"https://releases.hashicorp.com"}

local versions=""
local version
local v

for v in $(curl -s "https://releases.hashicorp.com/${toolname}/" |
for v in $(curl -s "${releases_host}/${toolname}/" |
grep -o "${toolname}_[0-9]\+\.[0-9]\+\.[0-9]\+\(\(-\|+\)[a-z]\+-\?[0-9]*\)*"); do
version="${v#"${toolname}"_}"
if [[ -z ${versions} ]]; then
Expand Down