ferrtable/ferrtable-test/src/settings.rs

24 lines
719 B
Rust
Raw Normal View History

2025-09-15 00:56:01 -07:00
use anyhow::Result;
use config::Config;
use serde::Deserialize;
/// Test application configuration values.
#[derive(Clone, Deserialize)]
pub(crate) struct Settings {
pub(crate) access_token: String,
pub(crate) base_id: String,
pub(crate) table_id: String,
}
impl Settings {
/// Load configuration values from a file "ferrtable-test.config.*" and/or
/// environment variables prefixed with "FERRTABLE_TEST_".
pub(crate) fn load() -> Result<Settings> {
Ok(Config::builder()
.add_source(config::Environment::with_prefix("FERRTABLE_TEST"))
.add_source(config::File::with_name("ferrtable-test.config"))
.build()?
.try_deserialize()?)
}
}