elixir-toniq / vapor

Runtime configuration system for Elixir
MIT License
596 stars 37 forks source link

normalize keys to lists #30

Closed jeffweiss closed 5 years ago

jeffweiss commented 5 years ago

Prior to this commit, Vapor did not support nested keys or structures, which meant that all the configs would have to be specified at the top level. For example:

{
 "database_hostname":"localhost,
 "database_port":5432,
 "database_username":"postgres",
 "database_password":"postgres",
 "database_dbname:"my_app"
}

This commit allows for nested configurations coming in and will flatten then to a key-path list. The above example can now be specified as:

{
  "database": {
    "hostname":"localhost",
    "port":5432,
    "username":"postgres",
    "password":"postgres",
    "dbname":"my_app"
  }
}

If, for example, we're interested in the database port and we have the configuration both in the file and the corresponding environment variable of "APP_DATABASE_PORT", we can access the appropriate value using ["database", "port"].

Closes #14.

bgmarx commented 5 years ago

@jeffweiss I'll check this out tomorrow. Sorry for the delay... hectic Chanukah weekend :)