DB YAML Config Provider v0.1.0 DatabaseYamlConfigProvider View Source

A config provider that can load a Rails style database.yml file that has the following structure:

production:
  adapter: postgresql
  database: testdb
  username: testuser
  password: myPa$sw0rd
  host: pgsqlhost
  port: 5432

Usage

You need to register this DatabaseYamlConfigProvider as config provider in the releases section of your mix.exs file.

releases: [
  my_app: [
    config_providers: [
      {DatabaseYamlConfigProvider, path: "/production/shared/config/database.yml"}
    ],
    ...
  ]
]

By default, this config provider expects an ENV environment variable that contains the current hosting environment name to be present when booting the application.

Alternatively, you can set the environment directly when defining the config provider.

{DatabaseYamlConfigProvider,
 path: "/production/shared/config",
 env: "production"}

Or you can speficy another env var containing the particular hosting environment on application startup:

{DatabaseYamlConfigProvider,
 path: "/production/shared/config",
 env: {:system, "RAILS_ENV"}}

The same works for the location of the database file. You can specify an env var containing the path to a folder that contains the database.yml file:

{DatabaseYamlConfigProvider, path: {:system, "RELEASE_CONFIG_PATH"}}

When the filename deviates from database.yml you can customize it, too:

{DatabaseYamlConfigProvider,
 path: {:system, "RELEASE_CONFIG_PATH", "my_custom_database.yml"}}