From b7a0e0b96edc023a1bc1fa2bd4610091026c4d1d Mon Sep 17 00:00:00 2001 From: kjuulh Date: Tue, 22 Nov 2022 13:37:10 +0100 Subject: [PATCH] with executors WIP --- crates/octopush_cli/src/commands/execute.rs | 6 +++++- .../src/executor/default_executor.rs | 18 ++++++++++++++++++ crates/octopush_core/src/executor/executor.rs | 12 ++++++++++++ .../src/executor/executors/golang.rs | 0 .../src/executor/executors/mod.rs | 1 + crates/octopush_core/src/executor/mod.rs | 3 +++ crates/octopush_core/src/lib.rs | 1 + 7 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 crates/octopush_core/src/executor/default_executor.rs create mode 100644 crates/octopush_core/src/executor/executor.rs create mode 100644 crates/octopush_core/src/executor/executors/golang.rs create mode 100644 crates/octopush_core/src/executor/executors/mod.rs create mode 100644 crates/octopush_core/src/executor/mod.rs diff --git a/crates/octopush_cli/src/commands/execute.rs b/crates/octopush_cli/src/commands/execute.rs index 0160dc2..7deaab8 100644 --- a/crates/octopush_cli/src/commands/execute.rs +++ b/crates/octopush_cli/src/commands/execute.rs @@ -47,9 +47,13 @@ pub async fn execute_subcommand(args: &ArgMatches) -> eyre::Result<()> { repo_clones.push(tokio::spawn(async move { gp.clone_from_url(repo).await })); } + let mut paths = Vec::new(); for repo_clone in repo_clones { - let report = repo_clone.await??; + let path = repo_clone.await??; + paths.push(path); } + + kk } } diff --git a/crates/octopush_core/src/executor/default_executor.rs b/crates/octopush_core/src/executor/default_executor.rs new file mode 100644 index 0000000..f88d47e --- /dev/null +++ b/crates/octopush_core/src/executor/default_executor.rs @@ -0,0 +1,18 @@ +use async_trait::async_trait; + +use crate::schema::models::Action; + +use super::executor::Executor; + +pub struct DefaultExecutor; + +#[async_trait] +impl Executor for DefaultExecutor { + async fn execute(&self, action: Action) -> eyre::Result<()> { + match action { + Action::Go { entry } => todo!(), + } + + Ok(()) + } +} diff --git a/crates/octopush_core/src/executor/executor.rs b/crates/octopush_core/src/executor/executor.rs new file mode 100644 index 0000000..64c685d --- /dev/null +++ b/crates/octopush_core/src/executor/executor.rs @@ -0,0 +1,12 @@ +use std::sync::Arc; + +use async_trait::async_trait; + +use crate::schema::models::Action; + +#[async_trait] +pub trait Executor { + async fn execute(&self, action: Action) -> eyre::Result<()>; +} + +pub type DynExecutor = Arc; diff --git a/crates/octopush_core/src/executor/executors/golang.rs b/crates/octopush_core/src/executor/executors/golang.rs new file mode 100644 index 0000000..e69de29 diff --git a/crates/octopush_core/src/executor/executors/mod.rs b/crates/octopush_core/src/executor/executors/mod.rs new file mode 100644 index 0000000..2da05a6 --- /dev/null +++ b/crates/octopush_core/src/executor/executors/mod.rs @@ -0,0 +1 @@ +pub mod golang; diff --git a/crates/octopush_core/src/executor/mod.rs b/crates/octopush_core/src/executor/mod.rs new file mode 100644 index 0000000..941cabe --- /dev/null +++ b/crates/octopush_core/src/executor/mod.rs @@ -0,0 +1,3 @@ +pub mod default_executor; +pub mod executor; +mod executors; diff --git a/crates/octopush_core/src/lib.rs b/crates/octopush_core/src/lib.rs index 3dd45ad..0bc06ab 100644 --- a/crates/octopush_core/src/lib.rs +++ b/crates/octopush_core/src/lib.rs @@ -1,3 +1,4 @@ pub mod git; pub mod storage; pub mod schema; +pub mod executor;