Skip to content

Commit

Permalink
Match project style
Browse files Browse the repository at this point in the history
  • Loading branch information
OJFord authored and Zordrak committed Oct 1, 2022
1 parent 830c2ec commit 585877a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions libexec/tfenv-resolve-version
Original file line number Diff line number Diff line change
Expand Up @@ -129,24 +129,24 @@ fi;

if [[ "${version_requested}" =~ ^latest-allowed$ ]]; then
log 'info' 'Detecting latest allowable version...';
version_spec="$(grep -h required_version "${TFENV_DIR:-$(pwd)}"/{*.tf,*.tf.json} 2>/dev/null | rev | cut -d'"' -f2 | rev | cut -d, -f1)"
version_num="$(echo "$version_spec" | sed -E 's/[^0-9.]+//')"
version_spec="$(grep -h required_version "${TFENV_DIR:-$(pwd)}"/{*.tf,*.tf.json} 2>/dev/null | rev | cut -d'"' -f2 | rev | cut -d, -f1)";
version_num="$(echo "${version_spec}" | sed -E 's/[^0-9.]+//')";

case "$version_spec" in
case "${version_spec}" in
'>'*)
version_requested=latest
version_requested=latest;
;;
'<='*)
version_requested="$version_num"
version_requested="${version_num}";
;;
'~>'*)
version_without_rightmost="$(echo "$version_num" | rev | cut -d. -f2- | rev)"
version_requested="latest:^${version_without_rightmost}"
version_without_rightmost="$(echo "${version_num}" | rev | cut -d. -f2- | rev)";
version_requested="latest:^${version_without_rightmost}";
;;
*)
log 'error' "Unsupported version spec: '${version_spec}', only >, >=, <=, and ~> are supported."
log 'error' "Unsupported version spec: '${version_spec}', only >, >=, <=, and ~> are supported.";
;;
esac
esac;
fi;

if [[ "${version_requested}" =~ ^latest\:.*$ ]]; then
Expand Down

0 comments on commit 585877a

Please sign in to comment.