Skip to content

Commit

Permalink
chore(bors): merge pull request #548
Browse files Browse the repository at this point in the history
548: fix: use heck instead of covert_case for Train-Case r=niladrih a=niladrih

The Train-Case implementation on the covert_case crate seems to convert 'ma8' to 'Ma-8'. This isn't the expected result. Heck seems to get it right, 'Ma8'.

Co-authored-by: Niladri Halder <[email protected]>
  • Loading branch information
mayastor-bors and niladrih committed Sep 26, 2024
2 parents abff840 + 0544204 commit a4ca276
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion call-home/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ path = "src/bin/stats/main.rs"

[dependencies]
constants = { path = "../constants" }
convert_case = "0.4.0"
openapi = {path = "../dependencies/control-plane/openapi"}
kube = { version = "0.85.0", features = ["runtime", "derive"] }
k8s-openapi = { version = "0.19.0", features = ["v1_20"] }
Expand Down Expand Up @@ -56,3 +55,4 @@ mime = "0.3.17"

# parse prometheus output
prometheus-parse = "0.2.4"
heck = "0.4.1"
7 changes: 5 additions & 2 deletions call-home/src/common/constants.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use convert_case::{Case::Train, Casing};
use heck::ToTrainCase;
use std::{
env,
path::{Path, PathBuf},
Expand All @@ -13,7 +13,7 @@ pub fn product() -> String {
env::var(CALLHOME_PRODUCT_NAME_ENV)
.ok()
.filter(|v| !v.is_empty())
.map(|v| v.to_case(Train))
.map(|v| v.to_train_case())
.unwrap_or(::constants::product_train())
}

Expand Down Expand Up @@ -154,6 +154,9 @@ mod tests {
use crate::common::constants::{product, CALLHOME_PRODUCT_NAME_ENV};
use std::env::{remove_var as unset, set_var as set};

set(CALLHOME_PRODUCT_NAME_ENV, "ma8");
assert_eq!(product(), "Ma8".to_string());

set(CALLHOME_PRODUCT_NAME_ENV, "foo bar");
assert_eq!(product(), "Foo-Bar".to_string());

Expand Down
2 changes: 1 addition & 1 deletion constants/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ edition = "2021"

[dependencies]
utils = {path = "../dependencies/control-plane/utils/utils-lib" }
convert_case = "0.4.0"
heck = "0.4.1"
4 changes: 2 additions & 2 deletions constants/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use convert_case::Casing;
use heck::ToTrainCase;
use utils::constants::PRODUCT_DOMAIN_NAME;
pub use utils::PRODUCT_NAME;

/// Name of the product.
pub fn product_train() -> String {
PRODUCT_NAME.to_case(convert_case::Case::Train)
PRODUCT_NAME.to_train_case()
}

/// Helm release name label's key.
Expand Down

0 comments on commit a4ca276

Please sign in to comment.