Skip to content

Commit

Permalink
docs: Add a quickfix to handle special capitalization cases (vectordo…
Browse files Browse the repository at this point in the history
…tdev#17141)

* docs: Add a quickfix to handle special capitalization cases

Signed-off-by: Spencer Gilbert <spencer.gilbert@datadoghq.com>

* +amqp

Signed-off-by: Spencer Gilbert <spencer.gilbert@datadoghq.com>

* +pr feedback

Signed-off-by: Spencer Gilbert <spencer.gilbert@datadoghq.com>

---------

Signed-off-by: Spencer Gilbert <spencer.gilbert@datadoghq.com>
  • Loading branch information
spencergilbert authored Apr 13, 2023
1 parent db39d83 commit ba63e21
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions lib/vector-config-macros/src/configurable_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<String>() + iter.as_str(),
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::<String>() + iter.as_str(),
}
}
}
}

Expand Down

0 comments on commit ba63e21

Please sign in to comment.