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

Environment variable values? #255

Closed
inklesspen opened this issue Oct 29, 2014 · 4 comments
Closed

Environment variable values? #255

inklesspen opened this issue Oct 29, 2014 · 4 comments

Comments

@inklesspen
Copy link

In many hosting environments (Heroku and Docker come to mind), certain important application values such as DB host/port are provided via environment variables. Is there any recommended way to integrate this with a TOML config file?

Of course, I can establish a convention that certain properties in the config contain names of env variables instead of the actual values, but then I have to do type conversion/validation myself (such as for an integer value) instead of the TOML library doing it for me.

I think my ideal scenario would be the ability to do something like this:

foo = "${STRING_ENV_VAR}"
bar = ${INTEGER_ENV_VAR}

where the environment variables get substituted into the file before parsing and its expected that INTEGER_ENV_VAR will contain something that would be valid to have there without quotes, etc etc.

@pnathan
Copy link

pnathan commented Oct 29, 2014

I would hope that erb or other tool would be a better fit for templating.

@inklesspen
Copy link
Author

Those do work, but then you have the interaction of template syntax and toml syntax; can the toml editor support be made to work with that?

@redhotvengeance
Copy link
Contributor

Seems like this is something that should be done on a post-push build step, meaning after you push it'll trigger a script that would inject the env vars into the doc. Heroku does similar steps like this when building the database.yml for a Rails project.

@mojombo
Copy link
Member

mojombo commented Nov 8, 2014

Environment variable injection would be cool, but I think it falls outside the scope of TOML's goal of minimalism. TOML implementations could offer this as an option, or applications could provide it as well, both of which seem more appropriate than baking this behavior into the spec. Thanks for the thoughts!

@mojombo mojombo closed this as completed Nov 8, 2014
kenhys added a commit to kenhys/aptutil that referenced this issue Feb 25, 2018
Before:
  meta_dir = "/home/user/.../go-apt-cacher/meta"
  cache_dir = "/home/user/.../go-apt-cacher/cache"

After:
  meta_dir = "${HOME}/.../go-apt-cacher/meta"
  cache_dir = "${HOME}/.../go-apt-cacher/cache"

In TOML spec, environment variable is not defined yet and it won't be
added[1], but it is useful that environment variable is support in
go-apt-cacher layer.

[1] toml-lang/toml#255
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

4 participants