| |
pretty_env_logger::init_custom_env("RADICLE_NATIVE_CI_LOG");
|
| |
info!("radicle-native-ci starts");
|
| |
|
| - |
const ENV: &str = "RADICLE_NATIVE_CI";
|
| - |
let config = std::env::var(ENV).map_err(|e| NativeError::GetEnv(ENV, e))?;
|
| - |
let config = Config::read(Path::new(&config))?;
|
| - |
debug!("read config: {:#?}", config);
|
| + |
let config = Config::load_via_env()?;
|
| + |
|
| |
let state = &config.state;
|
| |
if !state.exists() {
|
| |
debug!("creating {}", state.display());
|
| |
}
|
| |
|
| |
impl Config {
|
| + |
fn load_via_env() -> Result<Self, NativeError> {
|
| + |
const ENV: &str = "RADICLE_NATIVE_CI";
|
| + |
let filename = std::env::var(ENV).map_err(|e| NativeError::GetEnv(ENV, e))?;
|
| + |
let filename = Path::new(&filename);
|
| + |
let config = Config::read(filename)?;
|
| + |
debug!("configuration from {}: {:#?}", filename.display(), config);
|
| + |
Ok(config)
|
| + |
}
|
| + |
|
| |
/// Read configuration specification from a file.
|
| |
fn read(filename: &Path) -> Result<Self, NativeError> {
|
| |
let file = std::fs::File::open(filename)
|