use std::path::PathBuf;
use std::sync::Arc;
use crate::env_source::SharedEnvSource;
use crate::{MergeLayer, OrthoError};
mod builder;
mod candidate_set;
mod candidates;
mod load;
mod outcome;
mod telemetry;
pub use builder::ConfigDiscoveryBuilder;
#[derive(Clone)]
pub struct ConfigDiscovery {
env_var: Option<String>,
explicit_paths: Vec<PathBuf>,
required_explicit_paths: Vec<PathBuf>,
app_name: String,
config_file_name: String,
dotfile_name: String,
project_file_name: String,
project_roots: Vec<PathBuf>,
env_source: SharedEnvSource,
}
impl std::fmt::Debug for ConfigDiscovery {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ConfigDiscovery")
.field("env_var", &self.env_var)
.field("app_name", &self.app_name)
.field("config_file_name", &self.config_file_name)
.field("dotfile_name", &self.dotfile_name)
.field("project_file_name", &self.project_file_name)
.field("explicit_paths", &self.explicit_paths.len())
.field(
"required_explicit_paths",
&self.required_explicit_paths.len(),
)
.field("project_roots", &self.project_roots.len())
.finish_non_exhaustive()
}
}
#[derive(Debug, Default)]
#[must_use]
pub struct DiscoveryLoadOutcome {
pub figment: Option<figment::Figment>,
pub required_errors: Vec<Arc<OrthoError>>,
pub optional_errors: Vec<Arc<OrthoError>>,
}
#[derive(Debug, Default)]
#[must_use]
pub struct LayerDiscoveryOutcome<T> {
pub value: T,
pub required_errors: Vec<Arc<OrthoError>>,
pub optional_errors: Vec<Arc<OrthoError>>,
}
pub type DiscoveryLayerOutcome = LayerDiscoveryOutcome<Option<MergeLayer<'static>>>;
pub type DiscoveryLayersOutcome = LayerDiscoveryOutcome<Vec<MergeLayer<'static>>>;
impl ConfigDiscovery {
#[must_use]
pub fn builder(app_name: impl Into<String>) -> ConfigDiscoveryBuilder {
ConfigDiscoveryBuilder::new(app_name)
}
}
#[cfg(test)]
mod telemetry_test_support;
#[cfg(test)]
mod tests;
#[cfg(test)]
mod dedup_tests;