use std::collections::{BTreeMap, BTreeSet};
use std::path::{Path, PathBuf};
use std::sync::{Arc, atomic::AtomicBool};
use crate::entities::daemons::Daemons;
use crate::entities::driver::PipelineDriver;
use crate::entities::info::ShortName;
use crate::entities::observe_executor::ObserveClient;
use crate::entities::placements::Placement;
use crate::entities::remote_host::RemoteHost;
use crate::entities::skipper::Skipper;
pub struct RunEnvironment<'a> {
pub master_pipeline: &'a str,
pub run_dir: &'a Path,
pub cache_dir: &'a Path,
#[allow(dead_code)]
pub config_dir: &'a Path,
pub project_dir: Option<&'a Path>,
pub storage_dir: &'a Path,
pub artifacts_dir: &'a Path,
pub artifacts_placements: &'a [Placement],
pub remotes: &'a BTreeMap<ShortName, RemoteHost>,
pub ignore: &'a BTreeSet<PathBuf>,
pub log_file: Option<&'a Path>,
pub new_build: bool,
pub containered_build: bool,
pub containered_run: bool,
pub ansible_run: bool,
pub daemons: Daemons,
pub observe_cli: &'a Option<ObserveClient>,
pub skipper: Skipper,
pub driver: PipelineDriver,
pub restart_requested: Option<Arc<AtomicBool>>,
}
pub async fn with_empty_env<T>(f: impl AsyncFn(RunEnvironment<'_>) -> T) -> T {
let empty_path = PathBuf::from(".");
let empty_str = String::new();
let empty_remotes = BTreeMap::new();
let empty_ignore = BTreeSet::new();
let env = RunEnvironment {
run_dir: &empty_path,
config_dir: &empty_path,
new_build: false,
cache_dir: &empty_path,
project_dir: None,
storage_dir: &empty_path,
artifacts_dir: &empty_path,
artifacts_placements: &[],
remotes: &empty_remotes,
ignore: &empty_ignore,
log_file: None,
containered_build: false,
containered_run: false,
master_pipeline: &empty_str,
ansible_run: false,
daemons: Default::default(),
observe_cli: &None,
skipper: Default::default(),
driver: PipelineDriver::Deployer,
restart_requested: None,
};
f(env).await
}