feat: make template provider URLs configurable via environment variables#5
Merged
Conversation
bakayu
requested changes
Jun 17, 2026
bakayu
left a comment
Owner
There was a problem hiding this comment.
This solves the loading in a different template provider, but the problem of the schema of different providers being different still exists.
| // Load reads configuration from environment variables, falling back to defaults if not set. | ||
| func Load() (*Config, error) { | ||
| cfg := &Config{ | ||
| GitignoreListURL: getEnv("LQ_GITIGNORE_LIST_URL", "https://www.toptal.com/developers/gitignore/api/list?format=json"), |
Owner
There was a problem hiding this comment.
Could move the https://www.toptal.com/developers/gitignore/api/list?format=json to a const, see: https://github.com/bakayu/lq/pull/5/changes#r3428698374
Owner
|
Also, fix the lint and build errors |
bakayu
approved these changes
Jun 18, 2026
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
This PR resolves the issue regarding hardcoded provider URLs. It allows users to override the default Toptal and GitHub API URLs using shell environment variables. This ensures
lqcan be seamlessly used behind strict corporate firewalls, proxies, or with private/custom internal template servers.What Changed
internal/configpackage to act as the single source of truth for loading and validating environment variables.LQ_GITIGNORE_LIST_URLLQ_GITIGNORE_GET_URLLQ_LICENSE_LIST_URLLQ_LICENSE_GET_URL%splaceholder) immediately on startup. If a malformed URL is detected, it cleanly exits with1and a descriptive message before rendering the TUI.NewGitignoreProvider,NewLicenseProvider) to accept config arguments, decoupling them from the environment and making them highly testable.os.Statcheck before writing files to prevent silent obliteration of a user's existing.gitignoreorLICENSE.log.Fatalpanics withfmt.Fprintf(os.Stderr)andos.Exit(1)to prevent messy timestamps from leaking into the TUI.How to Test
lqwith no environment variables -> Proceeds normally with default URLs.export LQ_GITIGNORE_LIST_URL="not-a-valid-url"-> Fails fast on startup with a clean error message.export LQ_GITIGNORE_LIST_URL="https://custom.company.com/api/gitignores"-> Successfully overrides the default endpoint.Resolves #3