Weave

Hex.pmHex.pmHex.pmBuild StatusCoverage Status

A JIT configuration loader for Elixir

About

This library makes it possible to load configuration, especially secrets, from disk (Ala Docker Swarm / Kubernetes) on start-up.

Installation

def deps do
[{:weave, "~> 1.0.0"}]
end

Configuration

config :weave,
file_directory: "path/to/secrets"
environment_prefix: "MYAPP_"
handler: Your.Handler

Handler

Your handler should be prepared to handle the files, based on their name, within your file_directory.

handle_configuration/2 should return a tuple with the :app to set the key value pair on.

Weave will handle merging, so try not to worry about that 😄

defmodule Your.Handler do
def handle_configuration("some_file_name", value) do
{:app, :key, value}
end
end

Loading Configuration

You'll need to add the following to your start function, before to prepare your supervisor:

Weave.Loaders.File.load_configuration()
Weave.Loaders.Environment.load_configuration()

Logging

Weave may log sensitive information at the debug level, stick to info in production.

Contributing

Running Tests with Docker

$ docker-compose run --rm elixir

Next Steps

[x] Add tests for merge/2 [x] Load configuration from environment variables [ ] Documentation [ ] Add :loaders to specify, through config, which loaders to run and provide a single entrypoint Weave.load_configuration/0 [ ] Auto-wiring so a handler isn't needed. Contents of file would be {:app, :key, :value}

Thanks

Thanks for @sasa1977, @bitwalker and @OvermindDL1 for their advice on putting this together