feat: Add file:// URL scheme support for local release lists#609
Open
konan625 wants to merge 1 commit into
Open
feat: Add file:// URL scheme support for local release lists#609konan625 wants to merge 1 commit into
konan625 wants to merge 1 commit into
Conversation
Support offline version resolution by allowing file:// URLs in LIST_URL environment variables. This enables air-gapped installations, restricted CI runners, and enterprise networks to resolve versions from local files without network access. Changes: - pkg/download/download.go: Detect file:// URLs and read from local filesystem - pkg/download/download_test.go: Add tests for file:// URL handling - versionmanager/retriever/terraform/terraformretriever.go: Handle file:// URLs in path joining instead of url.JoinPath() - README.md: Document file:// URL scheme support with examples Fixes tofuutils#601 Signed-off-by: konan625 <aanchal625121@gmail.com>
dvaumoron
self-requested a review
July 6, 2026 15:54
dvaumoron
reviewed
Jul 6, 2026
| func Bytes(ctx context.Context, urlStr string, display func(string), checker ResponseChecker, requestOptions ...RequestOption) ([]byte, error) { | ||
| //Handle file:// URLs | ||
| //renaming urlstr to url to avoid shadowing the package name (net/url) | ||
| scheme, _, ok := strings.Cut(urlStr, "://") |
Contributor
There was a problem hiding this comment.
maybe better to use CutPrefix
dvaumoron
reviewed
Jul 6, 2026
| return value, nil | ||
| } | ||
|
|
||
| func bytesFromFile(fileURL string) ([]byte, error) { |
Contributor
There was a problem hiding this comment.
if you use CutPrefix in the caller, here you can have path directly as parameter and remove the TrimPrefix call
dvaumoron
reviewed
Jul 6, 2026
| return nil, err | ||
| listURL := r.conf.Tf.GetListURL() | ||
| var baseURL string | ||
| if strings.HasPrefix(listURL, "file://") { |
Contributor
There was a problem hiding this comment.
here, HasPrefix and TrimPrefix can be replaced with CutPrefix too
dvaumoron
reviewed
Jul 6, 2026
| // return nil, err | ||
| // } | ||
| var releasesURL string | ||
| if strings.HasPrefix(baseURL, "file://") { |
Contributor
There was a problem hiding this comment.
probably better to store in a local var that it was a file scheme, instead of checking several times
Contributor
There was a problem hiding this comment.
suggested improvements :
- you can have a local var
jointypedfunc(string, string) (string, error)(wrapfilepath.Jointo match the signature in file use case) - concatenation of
"file://"prefix should be done once at the end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Support offline version resolution by allowing
file://URLs inLIST_URLenvironment variables. This enables air-gapped installations, restricted CI runners,
and enterprise networks to resolve versions from local files without network access.
Fixes #601
Changes
file://URLs and read from local filesystemfile://URL handlingfile://URLs with filepath joiningTesting
✅ All unit tests pass
✅ Backward compatible - HTTP still works
✅ Manual E2E: Verified offline version resolution
Usage
export TFENV_LIST_URL=file:///opt/releases tenv tf list-remoteResult