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 }
34
35 fn emit(
36 config: Config,
37 requests: Vec<Self::Request>,
38 ctx: &mut NodeCtx<'_>,
39 ) -> anyhow::Result<()> {
40 let repo_id = config.repo_id.context("missing config: repo_id")?.0;
41 let mut reqs = Vec::new();
42
43 for req in requests {
44 match req {
45 Request::GetRepoDir(req::GetRepoDir(v)) => reqs.push(v),
46 }
47 }
48
49 if reqs.is_empty() {
50 return Ok(());
51 }
52
53 let path = ctx.reqv(|v| flowey_lib_common::git_checkout::Request::CheckoutRepo {
54 repo_id,
55 repo_path: v,
56 persist_credentials: false,
57 });
58
59 ctx.emit_minor_rust_step("resolve OpenVMM repo requests", move |ctx| {
60 let path = path.claim(ctx);
61 let vars = reqs.claim(ctx);
62 move |rt| {
63 let path = rt.read(path);
64 for var in vars {
65 rt.write(var, &path)
66 }
67 }
68 });
69
70 Ok(())
71 }
72}