feat(conf): add JSON config file support#2540
Merged
Merged
Conversation
Adds two new replace directives to go.mod which point to the newly
created internal/forks directory:
github.com/joho/godotenv => ./internal/forks/godotenv
github.com/kelseyhightower/envconfig => ./internal/forks/envconfig
Each one is clone of the version we use from the public repos with
no a dditional changes made. This may be a repeatable pattern we
could use to work around some limitations of older packages and
allow reaching into internals to ease migrating away from them.
The first step was moving configuration loading out of the conf package to make it easier to reason about and create a clear api boundary between loading and all other operations. This required updating a good number of files, but no behavioral changes were introduced so it is simple enough to audit. The only other notable change was moving a couple e2ecfg functions into a separate package to allow them to be used without causing import cycles.
This change adds a new loader.go file within the confload pkg which adds support for loading `.json` configuration files along side existing `.env` files. The loader has been wired into the serve command which required propagation to the reloader. I've done this with the goal of minimal blast radius, a future commit may provide a more defensive interface to prevent accidentally bypassing the new configuraiton loading logic. I've omitted tests in this commit as testing is still ongoing but wanted to get the change avialable for early review.
This comment has been minimized.
This comment has been minimized.
After finishing all the various test scenarios I've made a couple minor changes: * Changed API to not store file or dir * Removed the file checking from the config reloader, leaving the filtering as a Loader concern I've verified to the best of my ability that there are no changes in behavior between the current loader and the global funcs, other than supporting .env and .json.
Originally added envconfig so I may add a function which loads config from a map instead of the os.Env. I think it would still be good to do that at some point to prevent all the modifications to the processes env map at runtime, but preserving them for now.
fadymak
reviewed
Jun 3, 2026
Contributor
fadymak
left a comment
There was a problem hiding this comment.
Nice work! 👏 Left a few small comments.
- For the fallback, do we need to update the poller for
.jsonfiles too (ref) - What happens to env values with the
$symbol without intending to interpolate (e.g.:$messageTypefromGOTRUE_SMTP_HEADERS)?
Do we need to run the forked module tests explicitly (cd internal/forks/godotenv && go test ./...)?
fadymak
approved these changes
Jun 5, 2026
Contributor
fadymak
left a comment
There was a problem hiding this comment.
Nice work @cstockton 🎉 Approving to unblock, just some small nits/cleanup:
- I believe the tests for the forked modules aren't running in CI — would you mind adding them please?
- Only the
servecommand is wired up with the new.jsonfile support. Looks like we're missing themigrate,gotrue,admin, ... commands (mostly just for completeness)
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.
Adds two new replace directives to
go.modwhich point to the newly createdinternal/forksdirectory:github.com/joho/godotenv=>./internal/forks/godotenvgithub.com/kelseyhightower/envconfig=>./internal/forks/envconfigEach one is clone of the version we use from the public repos with no additional changes made. This may be a repeatable pattern we could use to work around some limitations of older packages and allow reaching into internals to ease migrating away from them.