From b35720943bd6854a737a8b0e7f625138cabc0d1d Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Wed, 23 Oct 2024 11:07:26 +0000 Subject: [PATCH] distver.plugin.sh: add terraform_install --- data/_usr.env/distver.plugin.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/data/_usr.env/distver.plugin.sh b/data/_usr.env/distver.plugin.sh index 4ad7b8b..d918174 100644 --- a/data/_usr.env/distver.plugin.sh +++ b/data/_usr.env/distver.plugin.sh @@ -575,6 +575,37 @@ docker_compose_install() { docker-compose version } +terraform_install() { + local ver="$1" + local goos goarch + local zipf + local url + + if test -z "$ver"; then + ver=1.9.8 + __errmsg "Defaulting to version $ver, see the doc for recent details" + __errmsg "" + __errmsg " https://developer.hashicorp.com/terraform/install" + fi + goos="$(go_os)" + goarch="$(go_arch)" + zipf="terraform_${ver}_${goos}_${goarch}.zip" + url="https://releases.hashicorp.com/terraform/${ver}/$zipf" + + local tmpd + tmpd="$(mktemp -d terraform_install.XXX)" + ( + cd "$tmpd" + mget \ + --count 4 \ + --url "$url" + unzip "$zipf" + mv terraform "$o_usr_env/bin/terraform" + terraform version + ) + rm -rf "$tmpd" +} + docker_buildx_install() { local goos goarch local ver