figment_file_env_provider

Crates.iofigment_file_env_provider
lib.rsfigment_file_env_provider
version0.2.0
sourcesrc
created_at2022-09-08 01:47:27.649367
updated_at2022-09-08 12:10:08.341156
descriptionA Figment provider to read from env or files
homepagehttps://github.com/nitnelave/figment_file_env_provider
repositoryhttps://github.com/nitnelave/figment_file_env_provider
max_upload_size
id660732
size18,659
nitnelave (nitnelave)

documentation

https://docs.rs/figment_file_env_provider

README

Figment FileEnv Provider   ci.svg crates.io docs.rs

Figment provider for optionally file-based env config values.

use serde::Deserialize;
use figment::{Figment, providers::Env};
use figment_file_env_provider::FileEnv;

#[derive(Deserialize)]
struct Config {
  frobnicate: String,
  foo: u64,
}

let config: Config = Figment::new()
    .merge(FileEnv::from_env(Env::prefixed("APP_")))
    .extract()?;

Overview

This crate contains the FileEnv provider for Figment, to allow loading configuration values from either environment variables or files. This is especially useful for secret management in combination with containers.

For instance, to pass an API key to the configuration, you could use either the environment variable API_KEY=abc123deadbeef, or you could write that API key to a file /secrets/api_key and pass the env variable API_KEY_FILE=/secrets/api_key.

See the documentation for a detailed usage guide and more information.

Usage

Add the following to your Cargo.toml:

[dependencies]
figment = { version = "0.10", features = ["env"] }
figment_file_env_provider = { version = "0.1" }

License

Figment_file_env_provider is licensed under either of the MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT).

Commit count: 17

cargo fmt