23 lines
719 B
Rust
23 lines
719 B
Rust
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()?)
|
|
}
|
|
}
|