Skip to content

Commit

Permalink
Add option for disable list remote on install step
Browse files Browse the repository at this point in the history
  • Loading branch information
Nmishin committed Dec 30, 2023
1 parent 0e1e73a commit 05a9b5f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,19 @@ functionality will be restored.
TOFUENV_REVERSE_REMOTE=1 tofuenv list-remote
```

##### `TOFUENV_SKIP_LIST_REMOTE`

Integer (Default: 0)

Skip list remote versions in installation step. Can be useful for a custom remote, such as Artifactory.

Disabled: 0
Enable: any other value

```console
TOFUENV_SKIP_LIST_REMOTE=1 tofuenv install 1.6.0-rc1
```

##### `TOFUENV_CONFIG_DIR`

Path (Default: `$TOFUENV_ROOT`)
Expand Down
14 changes: 8 additions & 6 deletions libexec/tofuenv-install
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ declare regex="${resolved##*\:}";
log 'debug' "Processing install for version ${version}, using regex ${regex}";

if [[ ${version} =~ ${regex:-not} ]]; then
log 'debug' "Version and regex matched"
log 'debug' "Version and regex matched";
else
log 'debug' "Version and regex not matched"
remote_version="$(tofuenv-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
log 'debug' "Version and regex not matched";
if [ "${TOFUENV_SKIP_LIST_REMOTE:-0}" -eq 0 ]; then
remote_version="$(tofuenv-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;
fi;

dst_path="${TOFUENV_CONFIG_DIR}/versions/${version}";
if [ -f "${dst_path}/tofu" ]; then
Expand Down Expand Up @@ -181,7 +183,7 @@ case "${status}" in
403) log 'error' "GitHub Rate limits exceeded" ;;
404) log 'error' "No versions matching '${requested:-$version}' found in remote" ;;
*) log 'error' "Unknown error, status code = ${status}" ;;
esac
esac;

log 'info' "Downloading SHA hash file from ${version_url}/${shasums_name}";
curlw -s -f -L -o "${download_tmp}/${shasums_name}" "${version_url}/${shasums_name}" || log 'error' 'SHA256 hashes download failed';
Expand Down

0 comments on commit 05a9b5f

Please sign in to comment.