Skip to content

Commit

Permalink
changed const to variables
Browse files Browse the repository at this point in the history
  • Loading branch information
devkelley committed Oct 26, 2023
1 parent 960adcd commit 6a63d81
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions core/common/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,25 +186,25 @@ pub async fn get_service_uri(
/// # Arguments
/// * `uri` - The uri to potentially modify.
pub fn get_uri(uri: &str) -> Result<String, Status> {
#[cfg(feature = "containerize")]
//#[cfg(feature = "containerize")]
let uri = {
// Container env variable names.
const HOST_GATEWAY_ENV_VAR: &str = "HOST_GATEWAY";
const LOCALHOST_ALIAS_ENV_VAR: &str = "LOCALHOST_ALIAS";
let host_gateway_env_var: &str = "HOST_GATEWAY";
let host_alias_env_var: &str = "LOCALHOST_ALIAS";

// Return an error if container env variables are not set.
let host_gateway = env::var(HOST_GATEWAY_ENV_VAR).map_err(|err| {
let host_gateway = env::var(host_gateway_env_var).map_err(|err| {
Status::failed_precondition(format!(
"Unable to get environment var '{HOST_GATEWAY_ENV_VAR}' with error: {err}"
"Unable to get environment var '{host_gateway_env_var}' with error: {err}"
))
})?;
let alias = env::var(LOCALHOST_ALIAS_ENV_VAR).map_err(|err| {
let host_alias = env::var(host_alias_env_var).map_err(|err| {
Status::failed_precondition(format!(
"Unable to get environment var '{LOCALHOST_ALIAS_ENV_VAR}' with error: {err}"
"Unable to get environment var '{host_alias_env_var}' with error: {err}"
))
})?;

uri.replace(&alias, &host_gateway) // DevSkim: ignore DS162092
uri.replace(&host_alias, &host_gateway)
};

Ok(uri.to_string())
Expand Down

0 comments on commit 6a63d81

Please sign in to comment.