From 7dd6660688816858e393bfdeaa901ab3cf2a8534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Wed, 19 Jul 2023 00:51:44 +0200 Subject: [PATCH] Added function for removing old terraform version at MACOS. It leaves only 2 latest versions --- .local/bin/Update-pkg | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.local/bin/Update-pkg b/.local/bin/Update-pkg index 7b9958b..b7f9300 100755 --- a/.local/bin/Update-pkg +++ b/.local/bin/Update-pkg @@ -69,6 +69,12 @@ function install_terraform() { brew install tflint -q brew install tfenv -q TFENV_ARCH=amd64 tfenv install latest + TFENV_VER_ARRAY=($(tfenv list | grep -ioE ' [0-9.]+' | sed -e '1,2d')) + if [ "${#TFENV_VER_ARRAY[@]}" -gt "2" ]; then + for i in "${TFENV_VER_ARRAY[@]}"; do + tfenv uninstall "$i" && timestamp "Removed - terraform '$i' version" + done + fi else GO111MODULE=on go install github.com/hashicorp/terraform@latest curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash