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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#![allow(missing_docs)]
use std::collections::{HashMap, HashSet};

use enum_dispatch::enum_dispatch;
use vector_lib::configurable::{configurable_component, NamedComponent};

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

#[cfg(feature = "secrets-aws-secrets-manager")]
mod aws_secrets_manager;
mod directory;
mod exec;
mod file;
mod test;

/// Configurable secret backends in Vector.
#[allow(clippy::large_enum_variant)]
#[configurable_component]
#[derive(Clone, Debug)]
#[enum_dispatch(SecretBackend)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum SecretBackends {
    /// File.
    File(file::FileBackend),

    /// Directory.
    Directory(directory::DirectoryBackend),

    /// Exec.
    Exec(exec::ExecBackend),

    /// AWS Secrets Manager.
    #[cfg(feature = "secrets-aws-secrets-manager")]
    AwsSecretsManager(aws_secrets_manager::AwsSecretsManagerBackend),

    /// Test.
    #[configurable(metadata(docs::hidden))]
    Test(test::TestBackend),
}

// TODO: Use `enum_dispatch` here.
impl NamedComponent for SecretBackends {
    fn get_component_name(&self) -> &'static str {
        match self {
            Self::File(config) => config.get_component_name(),
            Self::Directory(config) => config.get_component_name(),
            Self::Exec(config) => config.get_component_name(),
            #[cfg(feature = "secrets-aws-secrets-manager")]
            Self::AwsSecretsManager(config) => config.get_component_name(),
            Self::Test(config) => config.get_component_name(),
        }
    }
}