From 792dfcc15315622fc6d351fb669673d6bf2383c4 Mon Sep 17 00:00:00 2001 From: Yagmur Guraslan Date: Thu, 15 Dec 2022 16:10:09 +0000 Subject: [PATCH] Add env variable to skip listing remote versions before installation This is a genuine use case where you're using artifactory virtual repository like structure. Artifactory acts as a proxy between and list only the versions downloaded beforehand. This causes tfenv to fail stating that the version doesn't exist in the remote repository. --- libexec/tfenv-install | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libexec/tfenv-install b/libexec/tfenv-install index d13b384..022dc44 100755 --- a/libexec/tfenv-install +++ b/libexec/tfenv-install @@ -73,8 +73,10 @@ declare regex="${resolved##*\:}"; log 'debug' "Processing install for version ${version}, using regex ${regex}"; -remote_version="$(tfenv-list-remote | grep -e "${regex}" | head -n 1)"; -[ -n "${remote_version}" ] && version="${remote_version}" || log 'error' "No versions matching '${requested:-$version}' found in remote"; +if [ "${TFENV_SKIP_LIST_REMOTE:-0}" -eq 0 ]; then + remote_version="$(tfenv-list-remote | grep -e "${regex}" | head -n 1)"; + [ -n "${remote_version}" ] && version="${remote_version}" || log 'error' "No versions matching '${requested:-$version}' found in remote"; +fi dst_path="${TFENV_CONFIG_DIR}/versions/${version}"; if [ -f "${dst_path}/terraform" ]; then