fix(docker): Downloader of opentofu to specific version was broken, only latest worked - #1001
Conversation
GH_RELEASE_REGEX_SPECIFIC_VERSION expected the asset filename itself to
contain a 'v' prefix glued to the version (v${VERSION}_${TARGETOS}...),
but OpenTofu's release assets are named tofu_${VERSION}_${TARGETOS}...
with no 'v' - it only appears in the release tag's URL path segment.
The regex never matched, so `docker build --build-arg OPENTOFU_VERSION=X.Y.Z`
(pinning to anything other than 'latest') always failed to download.
Verified against the live GitHub API and a real end-to-end download.
Assisted-by: Sisyphus:claude-sonnet-5 claude
📝 WalkthroughWalkthroughThe OpenTofu installer updates its version-specific GitHub release filename regex from a ChangesOpenTofu installer
Estimated code review effort: 1 (Trivial) | ~2 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
latest worked
latest workedlatest worked
latest workedopentofu to specific version was broken, only latest worked
There was a problem hiding this comment.
Pull request overview
Fixes the OpenTofu installer’s GitHub release URL matching so pinned versions (e.g., OPENTOFU_VERSION=1.12.5) successfully resolve and download, instead of only latest working. This aligns the regex with OpenTofu’s real asset filename format (no v prefix in the filename).
Changes:
- Corrected the
GH_RELEASE_REGEX_SPECIFIC_VERSIONpattern intools/install/opentofu.shto match actual OpenTofu release asset URLs for a specific version.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This PR is included in version 1.108.1 🎉 |
hooks/_common.sh and tools/install/_common.sh both used
"${var^^}" for uppercasing (e.g. tflint -> TFLINT_VERSION), which
is bash 4+ only. macOS ships bash 3.2.57 by default (Apple's last
GPLv2 release) and this repo explicitly documents 'BASH 3.2.57 or
newer' as a supported baseline (README.md) - CI's macOS runner hit
exactly this with 'bad substitution' once the sdist-packaging fix
let it reach this code for the first time.
Replaced both with a portable 'tr' pipeline. Also fix
tools/install/opentofu.sh's GH_RELEASE_REGEX_SPECIFIC_VERSION: it
required a literal 'v' immediately before the version in the asset
*filename* (only the release *tag* has that 'v', e.g.
tofu_1.12.5_linux_amd64.tar.gz has no 'v'), so --tool-version pinning
for opentofu specifically always fell through to a blank curl URL.
(Same fix as already proposed standalone in PR #1001 against master;
duplicated here since this branch predates that PR and my test
suite's real-download coverage was tflint-only, so it never
exercised this path.)
Verified all three fixes against a real bash 3.2.57 (docker run
bash:3.2, matching macOS's exact version) end-to-end: real tflint
and real opentofu downloads both succeed and produce a working,
correctly-versioned cached binary.
Assisted-by: Sisyphus:claude-sonnet-5 claude
Description of your changes
What
This section was generated by AI.
tools/install/opentofu.sh'sGH_RELEASE_REGEX_SPECIFIC_VERSIONregex, which never matched any real OpenTofu release asset. It expected the filename itself to start with avglued to the version (v${VERSION}_${TARGETOS}...), but OpenTofu's actual asset filenames have novprefix (e.g.tofu_1.12.5_linux_amd64.tar.gz) - thevonly appears in the release tag's URL path segment (.../download/v1.12.5/tofu_1.12.5_linux_amd64.tar.gz), not the filename.--build-arg OPENTOFU_VERSION=X.Y.Zat Docker build time, or the--tool-version=X.Y.Zhook-config from #) silently failed to download - onlyOPENTOFU_VERSION=latestever worked, sinceGH_RELEASE_REGEX_LATESTdoesn't reference the version at all.Why
Accidentally found during work on a different PR.
How can we test changes
This section was generated by AI.
Also verified with a full end-to-end download/extract of the resulting URL - the extracted binary correctly reports
OpenTofu v1.12.5.Assisted-by
Specific models used per commit are specified in the commit messages.