fluentci_common/
envhub.rs1use std::sync::{Arc, Mutex};
2
3use anyhow::Error;
4use fluentci_core::deps::{Graph, GraphCommand};
5use fluentci_ext::envhub::Envhub as EnvhubExt;
6use fluentci_types::envhub::Envhub;
7use uuid::Uuid;
8
9pub fn envhub(graph: Arc<Mutex<Graph>>, reset: bool) -> Result<Envhub, Error> {
10 let mut graph = graph.lock().unwrap();
11
12 if reset {
13 graph.reset();
14 }
15
16 graph.runner = Arc::new(Box::new(EnvhubExt::default()));
17 graph.runner.setup()?;
18
19 let id = Uuid::new_v4().to_string();
20 graph.execute(GraphCommand::AddVertex(
21 id.clone(),
22 "envhub".into(),
23 "".into(),
24 vec![],
25 Arc::new(Box::new(EnvhubExt::default())),
26 ))?;
27
28 let envhub = Envhub { id };
29 Ok(envhub)
30}