datadog_agent_config_overlay_model/
smoke_test_support.rs

1//! Types necessary to keep the configuration smoke tests working. Intended to be transitional
2//! until we can get Saluki/ADP to stop deserializing directly from Agent configuration. At that
3//! time the smoke tests will be rendered inert and can be removed.
4use serde::{Deserialize, Serialize};
5
6/// A configuration consumer tracked by the legacy smoke-test registry.
7///
8/// Most variants name structs that consume Agent configuration directly. Sentinel variants track
9/// consumers that do not fit the legacy deserialization test model.
10#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)]
11pub enum ConfigurationStruct {
12    AggregateConfiguration,
13    ContainerdConfiguration,
14    DatadogEventsConfiguration,
15    DatadogLogsConfiguration,
16    DatadogServiceChecksConfiguration,
17    DogStatsDConfiguration,
18    DogStatsDDebugLogConfiguration,
19    DogStatsDMapperConfiguration,
20    DogStatsDPrefixFilterConfiguration,
21    RemoteAgentClientConfiguration,
22
23    /// Keys consumed through the typed configuration translation system.
24    TypedConfigSystem,
25
26    /// Keys read via `get_typed` / `try_get_typed` rather than struct deserialization.
27    #[serde(rename = "get_typed")]
28    GetTyped,
29
30    /// Sentinel for supported keys that are being promoted during the transition to
31    /// typed-configuration access. These were missing from our inventory when config smoke
32    /// testing was introduced and for various reasons may not be legitimate targets for that
33    /// testing modality. Regardless, these fields will be part of the typed translation system
34    /// and this sentinel can be removed when our testing model moves over to that system.
35    #[serde(rename = "NO_SMOKE")]
36    NoSmoke,
37}
38
39impl ConfigurationStruct {
40    /// Apparently we travel back and forth between string constant representation and the struct
41    /// names themselves. This function recovers the string constant name for a struct.
42    pub fn as_smoke_test_const(&self) -> &'static str {
43        match self {
44            ConfigurationStruct::AggregateConfiguration => "AGGREGATE_CONFIGURATION",
45            ConfigurationStruct::ContainerdConfiguration => "CONTAINERD_CONFIGURATION",
46            ConfigurationStruct::DatadogEventsConfiguration => "DATADOG_EVENTS_CONFIGURATION",
47            ConfigurationStruct::DatadogLogsConfiguration => "DATADOG_LOGS_CONFIGURATION",
48            ConfigurationStruct::DatadogServiceChecksConfiguration => "DATADOG_SERVICE_CHECKS_CONFIGURATION",
49            ConfigurationStruct::DogStatsDConfiguration => "DOGSTATSD_CONFIGURATION",
50            ConfigurationStruct::DogStatsDDebugLogConfiguration => "DOGSTATSD_DEBUG_LOG_CONFIGURATION",
51            ConfigurationStruct::DogStatsDMapperConfiguration => "DOGSTATSD_MAPPER_CONFIGURATION",
52            ConfigurationStruct::DogStatsDPrefixFilterConfiguration => "DOGSTATSD_PREFIX_FILTER_CONFIGURATION",
53            ConfigurationStruct::RemoteAgentClientConfiguration => "REMOTE_AGENT_CLIENT_CONFIGURATION",
54            ConfigurationStruct::TypedConfigSystem => "TYPED_CONFIG_SYSTEM",
55            ConfigurationStruct::GetTyped => "GET_TYPED",
56            ConfigurationStruct::NoSmoke => "NO_SMOKE",
57        }
58    }
59}