Skip to content

Commit fd43618

Browse files
authored
Merge pull request #450 from david-forster10/tfenv-skip-remote-check
Tfenv skip remote check
2 parents a3c943e + 037ef93 commit fd43618

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ tfenv install
126126
```
127127

128128
The `trust-tfenv` directive means that verification uses a copy of the
129-
Hashicorp OpenPGP key found in the tfenv repository. Skipping that directive
129+
Hashicorp OpenPGP key found in the tfenv repository. Skipping that directive
130130
means that the Hashicorp key must be in the existing default trusted keys.
131131
Use the file `${TFENV_INSTALL_DIR}/use-gnupg` to instead invoke the full `gpg` tool and
132132
see web-of-trust status; beware that a lack of trust path will not cause a
@@ -231,6 +231,20 @@ functionality will be restored.
231231
TFENV_REVERSE_REMOTE=1 tfenv list-remote
232232
```
233233

234+
##### `TFENV_SKIP_REMOTE_CHECK`
235+
236+
Integer (Default: 0)
237+
238+
When using a custom remote, such as Artifactory, lazy caching may be used meaning the versions
239+
returned by the remote aren't the full list available (more can be pulled on demand). This option
240+
disables the pre-install validation and will blindly pull the requested version from the remote. When
241+
using `latest` as the specified version, this will still rely on the latest version returned from the
242+
configured remote.
243+
244+
```console
245+
TFENV_SKIP_REMOTE_CHECK=1 tfenv install 1.14.5
246+
```
247+
234248
##### `TFENV_CONFIG_DIR`
235249

236250
Path (Default: `$TFENV_ROOT`)

libexec/tfenv-install

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ declare regex="${resolved##*\:}";
7373

7474
log 'debug' "Processing install for version ${version}, using regex ${regex}";
7575

76-
remote_version="$(tfenv-list-remote | grep -e "${regex}" | head -n 1)";
77-
[ -n "${remote_version}" ] && version="${remote_version}" || log 'error' "No versions matching '${requested:-$version}' found in remote";
76+
if [ "${TFENV_SKIP_REMOTE_CHECK:-0}" -eq 0 ]; then
77+
remote_version="$(tfenv-list-remote | grep -e "${regex}" | head -n 1)";
78+
[ -n "${remote_version}" ] && version="${remote_version}" || log 'error' "No versions matching '${requested:-$version}' found in remote";
79+
fi;
7880

7981
dst_path="${TFENV_CONFIG_DIR}/versions/${version}";
8082
if [ -f "${dst_path}/terraform" ]; then

0 commit comments

Comments
 (0)