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
use std::collections::{HashMap, HashSet};

use vector_lib::configurable::configurable_component;

use crate::{config::SecretBackend, signal};

/// Configuration for the `test` secrets backend.
#[configurable_component(secrets("test"))]
#[derive(Clone, Debug, Default)]
pub struct TestBackend {
    /// Fixed value to replace all secrets with.
    pub replacement: String,
}

impl_generate_config_from_default!(TestBackend);

impl SecretBackend for TestBackend {
    async fn retrieve(
        &mut self,
        secret_keys: HashSet<String>,
        _: &mut signal::SignalRx,
    ) -> crate::Result<HashMap<String, String>> {
        Ok(secret_keys
            .into_iter()
            .map(|k| (k, self.replacement.clone()))
            .collect())
    }
}