#configuration #env-var #variables #environment #compiler #config-file #yaml

confpiler

A configuration "compiler" to aid in turning configuration file(s) into environment variables

4 releases

0.2.2 Apr 21, 2022
0.2.1 Apr 11, 2022
0.2.0 Mar 8, 2022
0.1.0 Mar 6, 2022

#779 in Configuration

28 downloads per month
Used in confpiler_cli

MIT/Apache

33KB
535 lines

Confpiler (crate)

This crate provides a mechanism for "compiling" an ordered set of configuration files into a single, flattened representation suitable for exporting to environment variables.

Transforming

## default.yaml
foo:
    bar: 10
    baz: false
hoof: doof

## production.yaml
foo:
    baz: true

into something like

"FOO__BAR": "10"
"FOO__BAZ": "false"
"HOOF": "doof"

via

use confpiler::FlatConfig;

let (conf, warnings) = FlatConfig::builder()
    .add_config("foo/default")
    .add_config("foo/production")
    .build()
    .expect("invalid config");

All values are converted to strings, with simple arrays being collapsed to delimited strings (with the default separator being ,).

This does not support arrays containing more complex values like other arrays and maps.

The following formats are currently supported:

  • JOSN
  • TOML
  • YAML
  • INI

Dependencies

~2–2.9MB
~61K SLoC