You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement remote version listing — fetching and parsing available Terraform versions from HashiCorp's release infrastructure (or configured mirror).
Parent Epic
Part of #488 — Go Edition: Full Feature Parity Implementation
Motivation
The ability to list available remote versions underpins tfenv list-remote, tfenv install latest, and all version resolution that requires knowledge of what versions exist. It must handle custom mirrors (TFENV_REMOTE), version sorting, and the specific HTML format of releases.hashicorp.com.
Clean-Room Constraint
This is a clean-room implementation. Contributors MUST NOT read, reference, copy, or adapt source code from tofuutils/tenv, hashicorp/hc-install, or any other third-party tfenv-like tool. The sole reference is tfenv's own Bash source code, documentation, and test suite.
Proposed Design
Package Location
go/internal/list/ (remote listing component)
Remote Index Fetching
HTTP GET to ${TFENV_REMOTE}/terraform/ (default: https://releases.hashicorp.com/terraform/)
Parse HTML response to extract version numbers
The HTML format contains links like <a href="/terraform/1.5.0/">terraform_1.5.0</a>
Extract version strings using HTML parsing (not regex on HTML)
Version Sorting
Parse versions using hashicorp/go-version for correct semver sorting
Default: newest first (descending)
TFENV_REVERSE_REMOTE=1: oldest first (ascending)
Pre-release Filtering
By default, exclude pre-release versions (alpha, beta, rc)
Pre-release versions are included only when explicitly requested via regex patterns
Mirror Support
TFENV_REMOTE overrides the base URL
The path structure (/terraform/) is appended to the remote URL
Support authenticated mirrors via TFENV_NETRC_PATH
Reference libexec/tfenv-list-remote for the Bash implementation
The Bash edition uses curlw (a curl wrapper from lib/helpers.sh) — the Go edition uses net/http directly
The Bash edition extracts versions with grep -o '<a href="/terraform/[^"]*' | grep -o '[0-9]\+\.[0-9]\+\.[^"/]*' — the Go edition should use proper HTML parsing (golang.org/x/net/html or strings package with the known format)
Consider caching the version list for the duration of a single command invocation (not to disk) to avoid redundant HTTP requests
Summary
Implement remote version listing — fetching and parsing available Terraform versions from HashiCorp's release infrastructure (or configured mirror).
Parent Epic
Part of #488 — Go Edition: Full Feature Parity Implementation
Motivation
The ability to list available remote versions underpins
tfenv list-remote,tfenv install latest, and all version resolution that requires knowledge of what versions exist. It must handle custom mirrors (TFENV_REMOTE), version sorting, and the specific HTML format of releases.hashicorp.com.Clean-Room Constraint
This is a clean-room implementation. Contributors MUST NOT read, reference, copy, or adapt source code from
tofuutils/tenv,hashicorp/hc-install, or any other third-party tfenv-like tool. The sole reference is tfenv's own Bash source code, documentation, and test suite.Proposed Design
Package Location
go/internal/list/(remote listing component)Remote Index Fetching
${TFENV_REMOTE}/terraform/(default:https://releases.hashicorp.com/terraform/)<a href="/terraform/1.5.0/">terraform_1.5.0</a>Version Sorting
hashicorp/go-versionfor correct semver sortingTFENV_REVERSE_REMOTE=1: oldest first (ascending)Pre-release Filtering
Mirror Support
TFENV_REMOTEoverrides the base URL/terraform/) is appended to the remote URLTFENV_NETRC_PATHHTTP Client
net/httpstdlibHTTPS_PROXY/HTTP_PROXY/NO_PROXYenvironment variables (Go stdlib handles this automatically)tfenv/<version>Acceptance Criteria
${TFENV_REMOTE}/terraform/TFENV_REVERSE_REMOTE=1reverses sort orderTFENV_REMOTEoverrides the default remote URLTFENV_NETRC_PATHis used for authenticated requestshttptest.Serverwith realistic HTML fixtures — no network dependencyhashicorp/go-version(not string sorting)Dependencies
TFENV_REMOTE,TFENV_NETRC_PATHconfigurationImplementation Notes
libexec/tfenv-list-remotefor the Bash implementationcurlw(a curl wrapper fromlib/helpers.sh) — the Go edition usesnet/httpdirectlygrep -o '<a href="/terraform/[^"]*' | grep -o '[0-9]\+\.[0-9]\+\.[^"/]*'— the Go edition should use proper HTML parsing (golang.org/x/net/htmlorstringspackage with the known format)Labels
type:feature,priority:high,complexity:small,category:list