From 152a4721a2d16c7ab290394c3b39caf077b51866 Mon Sep 17 00:00:00 2001 From: Spencer Gilbert Date: Thu, 13 Apr 2023 10:24:50 -0400 Subject: [PATCH 1/3] docs: Add a quickfix to handle special capitalization cases Signed-off-by: Spencer Gilbert --- .../src/configurable_component.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/vector-config-macros/src/configurable_component.rs b/lib/vector-config-macros/src/configurable_component.rs index 16a3c0664d0b7..da990bb3d38e5 100644 --- a/lib/vector-config-macros/src/configurable_component.rs +++ b/lib/vector-config-macros/src/configurable_component.rs @@ -400,11 +400,26 @@ pub fn configurable_component_impl(args: TokenStream, item: TokenStream) -> Toke derived.into() } +// Properly capitalize labels, accounting for some exceptions +// TODO: Replace this with an explicit requirement for a "component_human_name" or similar. fn capitalize(s: &str) -> String { let mut iter = s.chars(); match iter.next() { None => String::new(), - Some(first) => first.to_uppercase().collect::() + iter.as_str(), + Some(first) => { + let name = first.to_uppercase().collect::() + iter.as_str(); + match name.as_str() { + "Ampq" | "Aws" | "Ec2" | "Ecs" | "Gcp" | "Hec" | "Http" | "Nats" | "Nginx" + | "Sqs" => name.to_uppercase(), + "Eventstoredb" => String::from("EventStoreDB"), + "Mongodb" => String::from("MongoDB"), + "Opentelemetry" => String::from("OpenTelemetry"), + "Postgresql" => String::from("PostgreSQL"), + "Pubsub" => String::from("Pub/Sub"), + "Statsd" => String::from("StatsD"), + _ => name, + } + } } } From e01c0b8a2c534e189e1d40222a62666baa87895d Mon Sep 17 00:00:00 2001 From: Spencer Gilbert Date: Thu, 13 Apr 2023 10:30:10 -0400 Subject: [PATCH 2/3] +amqp Signed-off-by: Spencer Gilbert --- lib/vector-config-macros/src/configurable_component.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vector-config-macros/src/configurable_component.rs b/lib/vector-config-macros/src/configurable_component.rs index da990bb3d38e5..ae7ba45bbe7ff 100644 --- a/lib/vector-config-macros/src/configurable_component.rs +++ b/lib/vector-config-macros/src/configurable_component.rs @@ -409,7 +409,7 @@ fn capitalize(s: &str) -> String { Some(first) => { let name = first.to_uppercase().collect::() + iter.as_str(); match name.as_str() { - "Ampq" | "Aws" | "Ec2" | "Ecs" | "Gcp" | "Hec" | "Http" | "Nats" | "Nginx" + "Amqp" | "Aws" | "Ec2" | "Ecs" | "Gcp" | "Hec" | "Http" | "Nats" | "Nginx" | "Sqs" => name.to_uppercase(), "Eventstoredb" => String::from("EventStoreDB"), "Mongodb" => String::from("MongoDB"), From a216aac8358de75a500b97eff53a001879a95aeb Mon Sep 17 00:00:00 2001 From: Spencer Gilbert Date: Thu, 13 Apr 2023 10:42:04 -0400 Subject: [PATCH 3/3] +pr feedback Signed-off-by: Spencer Gilbert --- .../src/configurable_component.rs | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/vector-config-macros/src/configurable_component.rs b/lib/vector-config-macros/src/configurable_component.rs index ae7ba45bbe7ff..de08cbaa2fa1f 100644 --- a/lib/vector-config-macros/src/configurable_component.rs +++ b/lib/vector-config-macros/src/configurable_component.rs @@ -403,21 +403,21 @@ pub fn configurable_component_impl(args: TokenStream, item: TokenStream) -> Toke // Properly capitalize labels, accounting for some exceptions // TODO: Replace this with an explicit requirement for a "component_human_name" or similar. fn capitalize(s: &str) -> String { - let mut iter = s.chars(); - match iter.next() { - None => String::new(), - Some(first) => { - let name = first.to_uppercase().collect::() + iter.as_str(); - match name.as_str() { - "Amqp" | "Aws" | "Ec2" | "Ecs" | "Gcp" | "Hec" | "Http" | "Nats" | "Nginx" - | "Sqs" => name.to_uppercase(), - "Eventstoredb" => String::from("EventStoreDB"), - "Mongodb" => String::from("MongoDB"), - "Opentelemetry" => String::from("OpenTelemetry"), - "Postgresql" => String::from("PostgreSQL"), - "Pubsub" => String::from("Pub/Sub"), - "Statsd" => String::from("StatsD"), - _ => name, + match s { + "Amqp" | "Aws" | "Ec2" | "Ecs" | "Gcp" | "Hec" | "Http" | "Nats" | "Nginx" | "Sqs" => { + s.to_uppercase() + } + "Eventstoredb" => String::from("EventStoreDB"), + "Mongodb" => String::from("MongoDB"), + "Opentelemetry" => String::from("OpenTelemetry"), + "Postgresql" => String::from("PostgreSQL"), + "Pubsub" => String::from("Pub/Sub"), + "Statsd" => String::from("StatsD"), + _ => { + let mut iter = s.chars(); + match iter.next() { + None => String::new(), + Some(first) => first.to_uppercase().collect::() + iter.as_str(), } } }