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 #35

Open
falzm opened this issue Sep 10, 2016 · 4 comments
Open

Support for environment variables #35

falzm opened this issue Sep 10, 2016 · 4 comments

Comments

@falzm
Copy link

falzm commented Sep 10, 2016

It would be super handy if Forge could support calling environment variables from configuration files, for example:

some_var = "blah"
some_section {
  base_dir = "%env{HOME}/myapp" # would resolve to "/home/user/myapp" after parsing
}

The token format is up to you (suggestions: %env{VARIABLE}, $env{VARIABLE}...), this is just to illustrate the idea :)

@falzm
Copy link
Author

falzm commented Sep 10, 2016

Note: a non-existent referenced environment variable would return an empty string instead of an error, if possible.

@brettlangdon
Copy link
Owner

hey @falzm sorry that it took me so long to respond here, unfortunately I stared at it for far too long in my email :(

I originally had a PR open previously for adding in environment variables #19, it was closed as it was previously determined that using environment variables for configuration should be left to the application rather than forge. As I think more and more about 12-factor apps, and thinking back on this, I am more than willing to open discussions again.

My thinking specific with 12fa is that I really like the nested config file approach, rather than having to do config.some_namespaced_config_name, you get config.some.namespaced.config.name, but still being able to override this from an environment variable would be nice.

Some options (syntax TDB) but:

some_section {
    value = ${SOME_SECTION_VALUE : "default value"}
}

Or maybe, we make an option that will just override settings from environment variables.

For example:

some_section {
    value = "default value"
}

When the parser gets to value it'll look to see if SOME_SECTION_VALUE environment variable exists and override the default value with that value.

I think both of these examples are a little different from what you are proposing which is more support for interpolation of environment variables in configuration options, but maybe being able to do SOME_SECTION_BASE_DIR=$HOME/myapp ./app is just as useful for your use case?

@falzm
Copy link
Author

falzm commented Sep 17, 2016

Hi @brettlangdon

Yes, that would work for me :)

@jeevatkm
Copy link
Contributor

@brettlangdon please let know if you're adding env variables support.

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

No branches or pull requests

3 participants