diff --git a/src/env/azure.rs b/src/env/azure.rs index 16830a8..c2bb37a 100644 --- a/src/env/azure.rs +++ b/src/env/azure.rs @@ -133,7 +133,7 @@ impl AzureConfig { if let Some(url) = &self.azure_keyvault_url { Ok(url.to_string()) } else if let Some(name) = &self.azure_keyvault_name { - Ok(format!("https://{}.vault.azure.net", name)) + Ok(format!("https://{name}.vault.azure.net")) } else { Err(AzureError::ConfigurationError(anyhow::Error::msg( "configuration is invalid (Clap should not validate that)", diff --git a/src/env/convert.rs b/src/env/convert.rs index f065164..f31765b 100644 --- a/src/env/convert.rs +++ b/src/env/convert.rs @@ -20,8 +20,8 @@ pub fn as_valid_env_name(name: String) -> Result { pub fn value_as_string(name: &str, v: Value) -> Result { match v { Value::String(s) => Ok(s), - Value::Bool(b) => Ok(format!("{}", b)), - Value::Number(n) => Ok(format!("{}", n)), + Value::Bool(b) => Ok(format!("{b}")), + Value::Number(n) => Ok(format!("{n}")), Value::Null => Ok("null".to_string()), _ => bail!("secret '{}' value is not convertible", name), } diff --git a/src/env/google.rs b/src/env/google.rs index 0c5c00c..c149efe 100644 --- a/src/env/google.rs +++ b/src/env/google.rs @@ -137,7 +137,7 @@ impl Vault for GoogleConfig { let project = self.google_project.as_ref().unwrap(); let response = manager .projects() - .secrets_list(&format!("projects/{}", project)) + .secrets_list(&format!("projects/{project}")) .page_size(250) .doit() .await @@ -205,7 +205,7 @@ impl GoogleConfig { ) -> Result { let data = manager .projects() - .secrets_versions_access(&format!("{}/versions/latest", name)) + .secrets_versions_access(&format!("{name}/versions/latest")) .doit() .await .map_err(GoogleError::SecretManagerError)? @@ -215,7 +215,7 @@ impl GoogleConfig { .data .ok_or(GoogleError::EmptySecret)?; let raw_bytes = base64 - .decode(&data) + .decode(data) .map_err(|e| GoogleError::WrongEncoding(anyhow::anyhow!(e)))?; String::from_utf8(raw_bytes).map_err(|e| GoogleError::WrongEncoding(anyhow::anyhow!(e))) } diff --git a/src/env/process_env.rs b/src/env/process_env.rs index a8a76fc..3eb5f7a 100644 --- a/src/env/process_env.rs +++ b/src/env/process_env.rs @@ -79,6 +79,8 @@ impl ProcessEnv { #[cfg(test)] mod tests { + use std::fmt::Display; + use super::*; impl ProcessEnv { @@ -97,9 +99,11 @@ mod tests { pub fn from_str(s: &str) -> Self { serde_json::from_str(s).unwrap() } + } - pub fn to_string(&self) -> String { - serde_json::to_string(self).unwrap() + impl Display for ProcessEnv { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", serde_json::to_string(self).unwrap()) } }