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

Investigate to implement an interpolate option #10

Open
rockneurotiko opened this issue Jun 27, 2019 · 0 comments
Open

Investigate to implement an interpolate option #10

rockneurotiko opened this issue Jun 27, 2019 · 0 comments

Comments

@rockneurotiko
Copy link
Owner

Sometimes you don't want just the variable in your config value, maybe you want it to be interpolated in a string, for example:

config :my_app, 
    some_url: "http://${MY_HOST}/wat

Some ideas about how to implement this, let me know which one you think it's the best one:

  • As an option:

{:system, "MY_HOST", interpolate: "http://${ENV}/wat"}

Pros:
Easy to implement
All the options of this library

Cons:
Not flexible, you can only use one env variable

  • As on option but uses the value:

{:system, "http://${MY_HOST}/wat", interpolate: true}

Pros:
Easy to read

Cons:
Not as easy to implement.
It's the same as replace_env_vars.
Lose all the flexibility of the library

  • Using the env name in a post process:

{:system, "MY_HOST", interpolate: "http://${MY_HOST}/wat"}

This would allow to do things like:

  path: {:system, "PATH"},
  url: {:system, "URL", interpolate: "http://${URL}/${PATH}"}

Pros:
Really flexible and can use all the features of the library

Cons:
We'll need to save all the env final values and do a second pass with all the interpolate after all the envs has been replated with their values, so, the performance of the library will suffer a little bit.

  • Do not implement and just use replace_env_vars
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