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

default config value environment interpolation #7

Open
progrium opened this issue Jan 23, 2017 · 0 comments
Open

default config value environment interpolation #7

progrium opened this issue Jan 23, 2017 · 0 comments

Comments

@progrium
Copy link
Contributor

To provide a little more flexibility in special cases, use https://github.com/mgood/go-posix for POSIX variable expansion. Main use case is in the web component we typically have:

com.Option("listen_addr", "0.0.0.0:8000", "Address and port to listen on")

This lets us change the whole listen address via config and environment. But when using Heroku, we get a port to listen on from environment, but it's not in full listen_addr form. In order to use it, we'd have to add complex code that defeats part of the point of comlab config. As a workaround, we do something like this:

com.Option("listen_addr", "0.0.0.0:"+os.Getenv("PORT"), "Address and port to listen on")

Now the default value is to listen with the PORT env var. But what if it's not set? Default config value should be valid if used. Sure we can set it to something else in dev.toml, but here is what it'd look like with POSIX expansion:

com.Option("listen_addr", "0.0.0.0:${PORT:-8000}", "Address and port to listen on")

Now if PORT is set, it uses that, otherwise it uses 8000. Ideally POSIX expansion can be applied to toml config as well!

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

1 participant