Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add a quickfix to handle special capitalization cases #17141

Merged
merged 3 commits into from
Apr 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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