Skip to content

Commit b551690

Browse files
committed
chore(config): generate datadog config witness trait
Generate, at build time, a witness trait and fallible driver over the supported Datadog Agent configuration surface. The generator parses the generated datadog_configuration.rs and emits, for every key inventoried as support: full or partial, one consume_<key> method on the DatadogConfigConsumer trait plus a drive() that calls each method exactly once. A translator that omits a newly supported key fails to compile, so the supported surface stays auditable from the schema overlay. Add the TranslateError type that drive() surfaces, and the Datadog source-language normalization metadata (KEY_ALIASES, DatadogRemapper) used to canonicalize keys before deserialization.
1 parent 137abc3 commit b551690

10 files changed

Lines changed: 1144 additions & 1 deletion

File tree

.vale/styles/config/vocabularies/technical/accept.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,9 @@ trivy
240240
Erlang
241241
OTP
242242
respawn(s|ed|ing)?
243+
typify
244+
snake_case
245+
unparsed
246+
stringify
247+
cutover
248+
[Aa]uditability

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/datadog-agent/config/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ license = { workspace = true }
66
repository = { workspace = true }
77

88
[dependencies]
9+
figment = { workspace = true }
910
serde = { workspace = true, features = ["derive"] }
1011
serde_json = { workspace = true }
1112

lib/datadog-agent/config/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use datadog_agent_config_overlay_model::{schema_gen, Files, SchemaOverlay};
66
mod classifier_gen;
77
#[path = "build/datadog_config_gen.rs"]
88
mod datadog_config_gen;
9+
#[path = "build/witness_gen.rs"]
10+
mod witness_gen;
911

1012
fn main() {
1113
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
@@ -17,11 +19,14 @@ fn main() {
1719
println!("cargo:rerun-if-changed=build.rs");
1820
println!("cargo:rerun-if-changed=build/classifier_gen.rs");
1921
println!("cargo:rerun-if-changed=build/datadog_config_gen.rs");
22+
println!("cargo:rerun-if-changed=build/witness_gen.rs");
2023

2124
let schema_path = files.schema.clone();
2225
let overlay = SchemaOverlay::load(files).unwrap_or_else(|e| panic!("{e}"));
2326
let schema_map = schema_gen::load_schema(&schema_path);
2427

2528
classifier_gen::generate(&overlay, &schema_map, &manifest_dir);
2629
datadog_config_gen::generate(&overlay, &schema_path, &manifest_dir);
30+
// Depends on the file datadog_config_gen just wrote: it parses src/datadog_configuration.rs.
31+
witness_gen::generate(&overlay, &manifest_dir);
2732
}

0 commit comments

Comments
 (0)