Hydroconf is a configuration management library for Rust, based on config-rs and heavily inspired by Python's dynaconf.
Features
- Inspired by the 12-factor configuration principles
- Effective separation of sensitive information (secrets)
- Layered system for multi environments (e.g. development, staging, production, etc.)
- Sane defaults, with a 1-line configuration loading
- Read from JSON, TOML, YAML, HJSON, INI files
The config-rs library is a great building block, but it does not provide a default mechanism to load configuration and merge secrets, while keeping the different environments separated. Hydroconf fills this gap.
Quickstart
Suppose you have the following file structure:
├── config
│ ├── .secrets.toml
│ └── settings.toml
└── your-executable
settings.toml
:
[]
= 5432
= 'localhost'
[]
= 'db-0'
.secrets.toml
:
[]
= 'a password'
[]
= 'a strong password'
Then, in your executable source (make sure to add serde = { version = "1.0", features = ["derive"] }
to your dependencies):
use Deserialize;
use Hydroconf;
If you compile and execute the program (making sure the executable is in the
same directory where the config
directory is), you will see the following:
Hydroconf will select the settings in the [default]
table by default. If you
set ENV_FOR_HYDRO
to production
, Hydroconf will overwrite them with the
production ones:
Settings can always be overridden with environment variables:
The description of all Hydroconf configuration options and how the program configuration is loaded can be found in the documentation.