Skip to content

feat(conf): add JSON config file support#2540

Merged
cstockton merged 19 commits into
masterfrom
cs/json-config
Jun 5, 2026
Merged

feat(conf): add JSON config file support#2540
cstockton merged 19 commits into
masterfrom
cs/json-config

Conversation

@cstockton
Copy link
Copy Markdown
Contributor

@cstockton cstockton commented May 26, 2026

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 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.

Chris Stockton and others added 2 commits May 26, 2026 08:03
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.
Chris Stockton and others added 3 commits May 29, 2026 10:33
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.
@blacksmith-sh

This comment has been minimized.

cstockton and others added 2 commits June 1, 2026 08:08
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.
@cstockton cstockton marked this pull request as ready for review June 2, 2026 23:15
@cstockton cstockton requested a review from a team as a code owner June 2, 2026 23:15
Chris Stockton and others added 4 commits June 3, 2026 05:43
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.
Copy link
Copy Markdown
Contributor

@fadymak fadymak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! 👏 Left a few small comments.

  • For the fallback, do we need to update the poller for .json files too (ref)
  • What happens to env values with the $ symbol without intending to interpolate (e.g.: $messageType from GOTRUE_SMTP_HEADERS)?

Do we need to run the forked module tests explicitly (cd internal/forks/godotenv && go test ./...)?

Comment thread internal/conf/confload/loader.go Outdated
Comment thread internal/conf/confload/loader.go Outdated
Comment thread internal/reloader/reloader.go
Comment thread internal/conf/confload/loader.go Outdated
Comment thread internal/conf/confload/loader.go Outdated
Copy link
Copy Markdown
Contributor

@fadymak fadymak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @cstockton 🎉 Approving to unblock, just some small nits/cleanup:

  1. I believe the tests for the forked modules aren't running in CI — would you mind adding them please?
  2. Only the serve command is wired up with the new .json file support. Looks like we're missing the migrate, gotrue, admin, ... commands (mostly just for completeness)

@cstockton cstockton merged commit e63fef9 into master Jun 5, 2026
8 checks passed
@cstockton cstockton deleted the cs/json-config branch June 5, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants