use std::path::Path;
use anyhow::{Context, Result};
use config::{Config as ConfigLib, File, FileFormat};
use tracing::info;
use crate::config::Config;
pub fn parse_config(path: &Path) -> Result<Config> {
info!("loading config from {:?}", path);
let config = ConfigLib::builder()
.add_source(File::from(path).format(FileFormat::Yaml))
.add_source(config::Environment::with_prefix("APPSERVICE_TEAMS").separator("__"))
.build()
.context("failed to load config file")?;
let config: Config = config
.try_deserialize()
.context("failed to deserialize config")?;
Ok(config)
}