comtrya_lib/steps/finalizers/
mod.rs

1use crate::atoms::Atom;
2
3mod env_vars_remove;
4mod output_contains;
5pub use env_vars_remove::RemoveEnvVars;
6
7pub use output_contains::OutputContains;
8
9#[allow(dead_code)]
10pub enum FlowControl {
11    Ensure(Box<dyn Finalizer>),
12    StopIf(Box<dyn Finalizer>),
13}
14
15/// Finalizers allow us to store data within the manifests KV store,
16/// or to end the execution of atoms for the action
17pub trait Finalizer {
18    fn finalize(&self, atom: &dyn Atom) -> anyhow::Result<bool>;
19}
20
21#[cfg(test)]
22pub mod test {
23    use super::*;
24    use anyhow::anyhow;
25
26    pub struct EchoFinalizer(pub bool);
27
28    impl Finalizer for EchoFinalizer {
29        fn finalize(&self, _atom: &dyn Atom) -> anyhow::Result<bool> {
30            Ok(self.0)
31        }
32    }
33
34    pub struct ErrorFinalizer();
35
36    impl Finalizer for ErrorFinalizer {
37        fn finalize(&self, _atom: &dyn Atom) -> anyhow::Result<bool> {
38            Err(anyhow!("ErrorFinalizer"))
39        }
40    }
41}