Skip to main content

floe_core/
lib.rs

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 profile;
10pub mod report;
11pub mod run;
12pub mod runner;
13pub mod runtime;
14pub mod state;
15pub mod vars;
16pub mod warnings;
17
18pub use crate::state::{inspect_entity_state_with_base, reset_entity_state_with_base};
19pub use add_entity::{add_entity_to_config, AddEntityOptions, AddEntityOutcome};
20pub use checks as check;
21pub use config::{resolve_config_location, ConfigLocation};
22pub use errors::ConfigError;
23pub use manifest::build_common_manifest_json;
24pub use profile::{
25    detect_unresolved_placeholders, parse_profile, parse_profile_from_str, validate_merged_vars,
26    validate_profile, ProfileConfig,
27};
28pub use run::events::{set_observer, RunEvent, RunObserver};
29pub use run::{run, run_with_base, DryRunEntityPreview, EntityOutcome, RunOutcome};
30pub use runner::{parse_run_status_from_logs, ConnectorRunStatus};
31pub use runtime::{DefaultRuntime, Runtime};
32pub use vars::{resolve_vars, VarSources};
33
34pub type FloeResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync>>;
35
36#[derive(Debug, Default)]
37pub struct ValidateOptions {
38    pub entities: Vec<String>,
39}
40
41#[derive(Debug, Default)]
42pub struct RunOptions {
43    pub run_id: Option<String>,
44    pub entities: Vec<String>,
45    pub dry_run: bool,
46}
47
48pub fn validate(config_path: &Path, options: ValidateOptions) -> FloeResult<()> {
49    let config_base = config::ConfigBase::local_from_path(config_path);
50    validate_with_base(config_path, config_base, options)
51}
52
53pub fn validate_with_base(
54    config_path: &Path,
55    _config_base: config::ConfigBase,
56    options: ValidateOptions,
57) -> FloeResult<()> {
58    let config = config::parse_config(config_path)?;
59    config::validate_config(&config)?;
60
61    if !options.entities.is_empty() {
62        run::validate_entities(&config, &options.entities)?;
63    }
64
65    Ok(())
66}
67
68pub fn load_config(config_path: &Path) -> FloeResult<config::RootConfig> {
69    config::parse_config(config_path)
70}
71
72pub fn validate_config_for_tests(config: &config::RootConfig) -> FloeResult<()> {
73    config::validate_config(config)
74}