Skip to content

Commit

Permalink
Don't overwrite .terraform-version files. Only change the default. Wa…
Browse files Browse the repository at this point in the history
…rn when overridden
  • Loading branch information
Zordrak committed Feb 16, 2020
1 parent e36f027 commit b7f72a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## 2.0.0-alpha1 (November 24, 2019)
## 2.0.0 (Unreleased)

* New logging library
* New bash4 dependency
* Massive testing, logging and loading refactoring
* Fix to 'use' logic: don't overwrite .terraform-version files

## 1.0.2 (October 29, 2019)

Expand Down
9 changes: 6 additions & 3 deletions libexec/tfenv-use
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,16 @@ target_path="${TFENV_ROOT}/versions/${version}";
[ -x "${target_path}/terraform" ] \
|| log 'error' "Version directory for ${version} is present, but the terraform binary is not executable! Manual intervention required.";

log 'info' "Switching to v${version}";

version_file="$(tfenv-version-file)";
log 'info' "Switching default version to v${version}";
version_file="${TFENV_ROOT}/version";
log 'debug' "Writing \"${version}\" to \"${version_file}\"";
echo "${version}" > "${version_file}" \
|| log 'error' "Switch to v${version} failed";

if [ "${version_file}" != "$(tfenv-version-file)" ]; then
log 'warn' "Default version file overridden by $(tfenv-version-file), changing the default version has no effect";
fi;

terraform --version 1>/dev/null \
|| log 'error' "'terraform --version' failed. Something is seriously wrong";
log 'info' "Switching completed";

0 comments on commit b7f72a5

Please sign in to comment.