1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use anyhow::Result;

use crate::{
    config::Config,
    contexts::{Context, ContextProvider},
};

pub struct VariablesContextProvider<'a> {
    pub config: &'a Config,
}

impl<'a> ContextProvider for VariablesContextProvider<'a> {
    fn get_prefix(&self) -> String {
        String::from("variables")
    }

    fn get_contexts(&self) -> Result<Vec<super::Context>> {
        let mut contexts = vec![];

        for (key, value) in self.config.variables.iter() {
            contexts.push(Context::KeyValueContext(
                key.to_owned(),
                value.to_owned().into(),
            ));
        }

        Ok(contexts)
    }
}