Skip to content

Commit

Permalink
Ensure env values return as lowercase; refine logs
Browse files Browse the repository at this point in the history
  • Loading branch information
tmknight committed Jan 7, 2024
1 parent c243696 commit 7d98b5e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion 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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "docker-autoheal"
version = "0.2.1"
version = "0.2.2"
authors = ["Travis M Knight <travis.knight@tmknight.net>"]
license = "MIT"
description = "Monitor and restart unhealthy docker containers"
Expand Down
16 changes: 7 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ async fn log_message(msg: &str) {
// Return environment variable
fn get_env(key: &str, default: &str) -> String {
match std::env::var(key) {
Ok(val) => return val,
Err(e) => return default.to_string(),
Ok(val) => return val.to_lowercase(),
Err(e) => return default.to_string().to_lowercase(),
}
}

Expand Down Expand Up @@ -78,7 +78,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Build container assessment criteria
let mut filters = HashMap::new();
filters.insert("health", vec!["unhealthy"]);
if autoheal_container_label != "ALL" {
if autoheal_container_label != "all" {
filters.insert("label", vec![&autoheal_container_label]);
}

Expand Down Expand Up @@ -112,12 +112,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

// Report what is transpiring
let msg0 = format!("Container '{}' ({}) unhealthy", name, id);
// todo
// let msg1 = format!(
// "Restarting '{}' with {}s timeout",
// name, autoheal_default_stop_timeout
// );
let msg1 = format!("Restarting '{}' now", name);
let msg1 = format!(
"Restarting '{}' with {}s timeout",
name, autoheal_default_stop_timeout
);
log_message(&msg0).await;
log_message(&msg1).await;

Expand Down

0 comments on commit 7d98b5e

Please sign in to comment.