Skip to content
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

Support for environment variables in config files #2098

Closed
adelphes opened this issue Sep 11, 2017 · 5 comments
Closed

Support for environment variables in config files #2098

adelphes opened this issue Sep 11, 2017 · 5 comments

Comments

@adelphes
Copy link

I've seen that this has come up a couple of times and dismissed with "not supported" or "use symlinks", but this would really be useful for creating different test & runtime configurations of Haraka. The use of environment variables in config files is also widely implemented in other software.

I think that adding support for expanding $XYZ or ${X Y Z} when reading configuration values wouldn't be too much work (feel free to tell me I'm wrong) and would provide a huge level of flexibility to Haraka without requiring the user to manually code symlinks to files/folders.

Related: #32, #1516

@KingNoosh KingNoosh self-assigned this Sep 11, 2017
@KingNoosh
Copy link
Member

KingNoosh commented Sep 11, 2017

The main reason why the push in config files I think is to pull users from qpsmtpd, I don't THINK it'll be difficult but I'll need to make it compatible with other ways.

All the current config files with extensions will look for ini, json and yaml. I could have it look for environmental variables prefixing with haraka seperating with maybe a dot.

I can probably draft this whenever I get time after work.

@smfreegard
Copy link
Collaborator

The main reason why the push in config files is to pull users from qpsmtpd

No - it's because we've had people asking for things like #32 e.g. NODE_ENV=dev/prod which would require something unusual and not just adding support for environment variables. e.g. it would require checking of the environment variable and then supplying individual values for 'prod', 'dev' and a default value or somesuch. So actually having a 'prod' and 'dev' config directories is therefore a simpler approach.

Adding environment variables would probably be quite easy, the only part that might be tricky is handling all of the different formats e.g. JSON, YAML etc. that Haraka config allows to use as $foo will probably need to be escaped in some way, however to handle the #32 case is probably quite difficult. Additionally there are multiple files where it wouldn't make sense e.g. config/plugins on config/host_list etc.

So the actual reason we've never added this before is simply because the core devs simply haven't had a use for this and could see multiple alternative ways to handle these cases.

If someone wants to have a go at designing how this should work - we should probably have a discussion about it here beforehand so we can evaluate the design etc.

@msimerson
Copy link
Member

We already have some basic elements of ENV use in haraka-config. It's used in some tests to choose test/config as the config directory instead of ./config. In other places we use this instead:

this.plugin.config = this.plugin.config.module_config(path.resolve('test'));

@KingNoosh
Copy link
Member

A clarification on this ticket is that @adelphes means that we'd like the ability to set config values via environmental variables.

Not load specific configs in specific node environments.

@msimerson
Copy link
Member

Duplicate of haraka/haraka-config#39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants