Skip to content

Commit 037ef93

Browse files
author
David Forster
committed
Adding option to skip checking remote versions before installing
1 parent 6204765 commit 037ef93

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

README.md

Lines changed: 9 additions & 3 deletions
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,13 +231,19 @@ functionality will be restored.
231231
TFENV_REVERSE_REMOTE=1 tfenv list-remote
232232
```
233233

234-
##### `TFENV_SKIP_LIST_REMOTE`
234+
##### `TFENV_SKIP_REMOTE_CHECK`
235235

236236
Integer (Default: 0)
237237

238238
When using a custom remote, such as Artifactory, lazy caching may be used meaning the versions
239239
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.
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+
```
241247

242248
##### `TFENV_CONFIG_DIR`
243249

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)