-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: use secrets instead of env vars for DSNs #1483
Conversation
fd79ddc
to
92a20c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome.
Please also roll this out to the PFI repo ASAP. You'll need to also change the Justfile as it is currently used to manage the DSN environment variables.
tmpDir := t.TempDir() | ||
|
||
cwd, err := os.Getwd() | ||
assert.NoError(t, err) | ||
|
||
rootDir := internal.GitRoot("") | ||
|
||
if ftlConfigPath != "" { | ||
t.Setenv("FTL_CONFIG", filepath.Join(tmpDir, ftlConfigPath)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use a path into the testdata
directory instead of one relative to the tmpDir. Otherwise we have a chicken and egg situation where the config can't be loaded until the module is copied over, and the config itself is used by FTL during startup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add a comment to run
describing the above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah good point, done on both counts
|
||
// DatabasesFromSecrets finds DSNs in environment variables and creates a map of databases. | ||
// | ||
// Environment variables should be in the format FTL_POSTGRES_DSN__<MODULENAME>_<DBNAME> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is no longer accurate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, thanks for catching that
// FTL_DSN_<MODULE>_<DBNAME> | ||
parts := strings.Split(sName, "_") | ||
if len(parts) != 4 { | ||
return nil, fmt.Errorf("invalid DSN secret key %q should have format FTL_DSN_MODULE_DBNAME", sName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use FTL_DSN_<MODULE>_<DBNAME>
in the error so it's clear what parts are variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea - done
Fixes #1427
database/ftl-project.toml was written using:
This PR only works thanks to this earlier PR: #1472