Skip to content

Commit

Permalink
Merge pull request #1 from Affirm/fix-tgenv-install-existing
Browse files Browse the repository at this point in the history
Fix tgenv install existing
  • Loading branch information
austinguo550 committed Sep 1, 2022
1 parent c853eb9 commit dd39fb2
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 70 deletions.
17 changes: 15 additions & 2 deletions libexec/tgenv-install
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,22 @@ else
regex="^${version_requested}$"
fi

echo "${version}"
echo "${regex}"

[ -n "${version}" ] || error_and_die "Version is not specified"
version="$(tgenv-list-remote | grep -e "${regex}" | head -n 1)"
[ -n "${version}" ] || error_and_die "No versions matching '${1}' found in remote"
# if the version is already installed on this host, don't attempt to fetch remote
# just switch to this version and save an API call
dst_path="${TGENV_ROOT}/versions/${version}"
if [[ -e "${dst_path}" ]]; then
echo "Terragrunt v${version} is already installed"
tgenv-use "${version}"
exit 0
# otherwise if the version is not already installed, find it in the remote versions and install it
else
version="$(tgenv-list-remote | grep -e "${regex}" | head -n 1)"
[ -n "${version}" ] || error_and_die "No versions matching '${1}' found in remote"
fi

dst_path="${TGENV_ROOT}/versions/${version}"
if [ -f "${dst_path}/terragrunt" ]; then
Expand Down
161 changes: 100 additions & 61 deletions list_all_versions_offline
Original file line number Diff line number Diff line change
@@ -1,61 +1,100 @@
0.18.2
0.13.19
0.13.18
0.13.17
0.13.16
0.13.15
0.13.14
0.13.13
0.13.12
0.13.11
0.13.10
0.13.9
0.13.8
0.13.7
0.13.6
0.13.5
0.13.4
0.13.3
0.13.2
0.13.1
0.13.0
0.12.25
0.12.24
0.12.23
0.12.22
0.12.21
0.12.20
0.12.19
0.12.18
0.12.17
0.12.16
0.12.15
0.12.14
0.12.13
0.12.12
0.12.11
0.12.10
0.12.9
0.12.8
0.12.7
0.12.6
0.12.5
0.12.4
0.12.3
0.12.2
0.12.1
0.12.0
0.11.1
0.11.0
0.10.3
0.10.2
0.10.1
0.10.0
0.9.9
0.9.8
0.9.7
0.9.6
0.9.5
0.9.4
0.9.3
0.9.2
0.38.7
0.38.6
0.38.5
0.38.4
0.38.3
0.38.2
0.38.1
0.38.0
0.37.4
0.37.3
0.37.2
0.37.1
0.37.0
0.36.12
0.36.11
0.36.10
0.36.9
0.36.8
0.36.7
0.36.6
0.36.5
0.36.4
0.36.3
0.36.2
0.36.1
0.36.0
0.35.20
0.35.19
0.35.18
0.35.17
0.35.16
0.35.15
0.35.14
0.35.13
0.35.12
0.35.11
0.35.10
0.35.9
0.35.8
0.35.7
0.35.6
0.35.5
0.35.4
0.35.3
0.35.2
0.35.1
0.35.0
0.34.3
0.34.2
0.34.1
0.34.0
0.33.2
0.33.1
0.33.0
0.32.6
0.32.5
0.32.4
0.32.3
0.32.2
0.32.1
0.32.0
0.31.11
0.31.10
0.31.9
0.31.8
0.31.7
0.31.6
0.31.5
0.31.4
0.31.3
0.31.2
0.31.1
0.31.0
0.30.7
0.30.6
0.30.5
0.30.4
0.30.3
0.30.2
0.30.1
0.30.0
0.29.10
0.29.9
0.29.8
0.29.7
0.29.6
0.29.5
0.29.4
0.29.3
0.29.2
0.29.1
0.29.0
0.28.24
0.28.23
0.28.22
0.28.21
0.28.20
0.28.19
0.28.18
0.28.17
2 changes: 1 addition & 1 deletion test/test_install_and_use.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ v=$(tgenv list-remote | grep 0.11.1 | head -n 1)
echo "### Install specific version"
cleanup || error_and_die "Cleanup failed?!"

v=0.9.9
v=0.35.13
(
tgenv install ${v} || exit 1
tgenv use ${v} || exit 1
Expand Down
12 changes: 6 additions & 6 deletions test/test_list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ source $(dirname $0)/helpers.sh \
echo "### List local versions"
cleanup || error_and_die "Cleanup failed?!"

for v in 0.12.15 0.12.9 0.11.1 0.10.0 0.9.3; do
for v in 0.35.13 0.35.14 0.35.15 0.35.16 0.35.17; do
tgenv install ${v} || error_and_proceed "Install of version ${v} failed"
done

result=$(tgenv list)
expected="$(cat << EOS
0.12.15
0.12.9
0.11.1
0.10.0
0.9.3
0.35.17
0.35.16
0.35.15
0.35.14
0.35.13
EOS
)"

Expand Down

0 comments on commit dd39fb2

Please sign in to comment.