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