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