flowey_lib_hvlite/
git_checkout_openvmm_repo.rs1use flowey::node::prelude::*;
8
9flowey_config! {
10 pub struct Config {
12 pub repo_id: Option<ConfigVar<String>>,
15 }
16}
17
18flowey_request! {
19 pub enum_struct Request {
20 GetRepoDir(pub WriteVar<PathBuf>),
22 }
23}
24
25new_flow_node_with_config!(struct Node);
26
27impl FlowNodeWithConfig for Node {
28 type Request = Request;
29 type Config = Config;
30
31 fn imports(ctx: &mut ImportCtx<'_>) {
32 ctx.import::<flowey_lib_common::git_checkout::Node>();
33 ctx.import::<flowey_lib_common::system_info::Node>();
34 }
35
36 fn emit(
37 config: Config,
38 requests: Vec<Self::Request>,
39 ctx: &mut NodeCtx<'_>,
40 ) -> anyhow::Result<()> {
41 let repo_id = config.repo_id.context("missing config: repo_id")?.0;
42 let mut reqs = Vec::new();
43
44 for req in requests {
45 match req {
46 Request::GetRepoDir(req::GetRepoDir(v)) => reqs.push(v),
47 }
48 }
49
50 if reqs.is_empty() {
51 return Ok(());
52 }
53
54 let path = ctx.reqv(|v| flowey_lib_common::git_checkout::Request::CheckoutRepo {
55 repo_id,
56 repo_path: v,
57 persist_credentials: false,
58 });
59
60 let printed_system_info = ctx.reqv(|v| flowey_lib_common::system_info::Request { done: v });
64
65 ctx.emit_minor_rust_step("resolve OpenVMM repo requests", move |ctx| {
66 printed_system_info.claim(ctx);
67 let path = path.claim(ctx);
68 let vars = reqs.claim(ctx);
69 move |rt| {
70 let path = rt.read(path);
71 for var in vars {
72 rt.write(var, &path)
73 }
74 }
75 });
76
77 Ok(())
78 }
79}