diff --git a/crates/cuddle-clusters/src/process.rs b/crates/cuddle-clusters/src/process.rs index 4203e1a..2dbe227 100644 --- a/crates/cuddle-clusters/src/process.rs +++ b/crates/cuddle-clusters/src/process.rs @@ -13,7 +13,25 @@ use tokio_stream::{wrappers::ReadDirStream, StreamExt}; use crate::components::{ConcreteComponent, IntoComponent}; pub async fn process() -> anyhow::Result<()> { - process_opts(Vec::::new(), ProcessOpts::default()).await + process_opts( + Vec::::new(), + ProcessOpts::default(), + None::, + ) + .await +} + +pub trait UploadStrategy { + fn upload(&self, input_path: &Path) -> BoxFuture<'_, anyhow::Result<()>>; +} + +#[derive(Default)] +pub struct NoUploadStrategy {} + +impl UploadStrategy for NoUploadStrategy { + fn upload(&self, input_path: &Path) -> BoxFuture<'_, anyhow::Result<()>> { + async move { Ok(()) }.boxed() + } } pub struct ProcessOpts { @@ -42,6 +60,7 @@ const CUDDLE_PLAN_PATH_PREFIX: &str = ".cuddle/base"; pub async fn process_opts( components: impl IntoIterator, opts: ProcessOpts, + upload_strategy: Option, ) -> anyhow::Result<()> { let components = components .into_iter() @@ -76,6 +95,10 @@ pub async fn process_opts( ) .await?; + if let Some(upload_strategy) = upload_strategy { + upload_strategy.upload(&opts.output).await?; + } + Ok(()) } diff --git a/crates/cuddle-clusters/tests/common.rs b/crates/cuddle-clusters/tests/common.rs index 9dedb4b..f8bea02 100644 --- a/crates/cuddle-clusters/tests/common.rs +++ b/crates/cuddle-clusters/tests/common.rs @@ -1,6 +1,9 @@ use std::{cmp::Ordering, collections::HashMap, path::Path}; -use cuddle_clusters::{process::ProcessOpts, ConcreteComponent, IntoComponent}; +use cuddle_clusters::{ + process::{NoUploadStrategy, ProcessOpts}, + ConcreteComponent, IntoComponent, +}; use walkdir::DirEntry; pub(crate) async fn run_test_with_components( @@ -29,6 +32,7 @@ pub(crate) async fn run_test_with_components( output: actual.clone(), variables: HashMap::default(), }, + None::, ) .await?; @@ -40,6 +44,7 @@ pub(crate) async fn run_test_with_components( output: expected.clone(), variables: HashMap::default(), }, + None::, ) .await?; }