Skip to content

feat(config): Make config elements overridable via environment variable#219

Closed
kreusel wants to merge 1 commit into
lowercasename:mainfrom
kreusel:make-config-overridable-from-env
Closed

feat(config): Make config elements overridable via environment variable#219
kreusel wants to merge 1 commit into
lowercasename:mainfrom
kreusel:make-config-overridable-from-env

Conversation

@kreusel

@kreusel kreusel commented Jul 16, 2025

Copy link
Copy Markdown

As for many (or just my) environments, you do not want to have passwords in configurations that may be stored in a git repository. So i wanted to have a way of configuring env var replacements inside the .toml file without changing to much.

Another possible solution would be to implement a more sophisticated config framework.

Example for config file (smtp_password will get replaced with value of $SMTP_PASSWORD):

[nodemailer]
smtp_server = "mail.example.com"
smtp_port = "587"
smtp_username = "noreply@example.com"
smtp_password = "$SMTP_PASSWORD"

Example for config file (smtp_password will get replaced with value of $SMTP_PASSWORD):
```
[nodemailer]
smtp_server = "mail.example.com"
smtp_port = "587"
smtp_username = "noreply@example.com"
smtp_password = "$SMTP_PASSWORD"
```
@lowercasename

Copy link
Copy Markdown
Owner

Ah, this is a lovely idea. I wonder if it would be a bit safer to parse the file as TOML first, and then replace the variables in the output JS object, knowing that they specifically start with a $ symbol. My worry here is what happens if I put a $ symbol in another variable, or in an API key, etc.

@kreusel

kreusel commented Jul 29, 2025

Copy link
Copy Markdown
Author

Fair point, had that idea too. Will have a look

halkeye added a commit to halkeye/gathio that referenced this pull request Nov 2, 2025
halkeye added a commit to halkeye/gathio that referenced this pull request Nov 14, 2025
@lowercasename

Copy link
Copy Markdown
Owner

I'm going to close this PR in favour of #232 - thank you for the original seed of the idea @kreusel!

@kreusel kreusel deleted the make-config-overridable-from-env branch May 4, 2026 09:34
@kreusel

kreusel commented May 4, 2026

Copy link
Copy Markdown
Author

Great thing 👍

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