Skip to content

Commit

Permalink
Fix empty env-vars validation as invalid values (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
boozook authored Oct 27, 2020
2 parents 344a9d1 + c46de04 commit 07fab29
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions cli/src/bin/dvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ struct Options {
}

fn main() -> Result<()> {
remove_empty_env_vars();
let options = Options::parse();
let _guard = init(&options.logging, &options.integrations);
main_internal(options)
Expand Down
19 changes: 19 additions & 0 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,22 @@ pub struct IntegrationsOptions {
#[cfg(feature = "sentry")]
pub sentry_env: Option<String>,
}

pub fn remove_empty_env_vars() {
use std::env;
[
DVM_LOG,
DVM_LOG_STYLE,
DVM_DATA_SOURCE,
DVM_SENTRY_DSN,
DVM_SENTRY_ENV,
]
.iter()
.for_each(|var| {
if let Ok(value) = env::var(var) {
if value.trim().is_empty() {
env::remove_var(var);
}
}
});
}

0 comments on commit 07fab29

Please sign in to comment.