1use std::path::Path;
2
3pub mod checks;
4pub mod config;
5pub mod errors;
6pub mod io;
7pub mod report;
8pub mod run;
9pub mod warnings;
10
11pub use checks as check;
12pub use config::{resolve_config_location, ConfigLocation};
13pub use run::{run, run_with_base, EntityOutcome, RunOutcome};
14
15pub type FloeResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync>>;
16
17#[derive(Debug)]
18pub(crate) struct ConfigError(pub(crate) String);
19
20impl std::fmt::Display for ConfigError {
21 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22 write!(f, "{}", self.0)
23 }
24}
25
26impl std::error::Error for ConfigError {}
27
28#[derive(Debug, Default)]
29pub struct ValidateOptions {
30 pub entities: Vec<String>,
31}
32
33#[derive(Debug, Default)]
34pub struct RunOptions {
35 pub run_id: Option<String>,
36 pub entities: Vec<String>,
37}
38
39pub fn validate(config_path: &Path, options: ValidateOptions) -> FloeResult<()> {
40 let config_base = config::ConfigBase::local_from_path(config_path);
41 validate_with_base(config_path, config_base, options)
42}
43
44pub fn validate_with_base(
45 config_path: &Path,
46 _config_base: config::ConfigBase,
47 options: ValidateOptions,
48) -> FloeResult<()> {
49 let config = config::parse_config(config_path)?;
50 config::validate_config(&config)?;
51
52 if !options.entities.is_empty() {
53 run::validate_entities(&config, &options.entities)?;
54 }
55
56 Ok(())
57}
58
59pub fn load_config(config_path: &Path) -> FloeResult<config::RootConfig> {
60 config::parse_config(config_path)
61}
62
63pub fn validate_config_for_tests(config: &config::RootConfig) -> FloeResult<()> {
64 config::validate_config(config)
65}