diff --git a/CHANGELOG.md b/CHANGELOG.md index d09edd7..b829292 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ## [Unreleased] +## 0.8.1 + +### Changed + +- Small change to how webhook and/or apprise are called for the sake of efficiency +- Updated license to GPL-3.0 + ## 0.8.0 ### Added diff --git a/Cargo.lock b/Cargo.lock index 656c627..75c20d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,7 +188,7 @@ dependencies = [ [[package]] name = "docker-autoheal" -version = "0.8.0" +version = "0.8.1" dependencies = [ "bollard", "chrono", diff --git a/Cargo.toml b/Cargo.toml index be0719c..7696847 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "docker-autoheal" -version = "0.8.0" +version = "0.8.1" authors = ["Travis M Knight"] -license = "MIT" +license = "GPL-3.0" description = "A cross-platform tool to monitor and remediate unhealthy Docker containers" readme = "README.md" homepage = "https://github.com/tmknight/docker-autoheal" edition = "2021" -rust-version = "1.74.1" +rust-version = "1.74" [dependencies] bollard = { version = "0.*", features = ["ssl"] } diff --git a/src/execute/looper.rs b/src/execute/looper.rs index 2b874ec..234a030 100644 --- a/src/execute/looper.rs +++ b/src/execute/looper.rs @@ -93,7 +93,8 @@ pub async fn start_loop( log_message(&msg1, WARNING).await; // Restart unhealthy container - match &docker_clone.restart_container(&id, restart_options).await { + let msg = match &docker_clone.restart_container(&id, restart_options).await + { Ok(()) => { // Log result let msg0 = format!( @@ -101,19 +102,7 @@ pub async fn start_loop( name, id ); log_message(&msg0, INFO).await; - // Send webhook - if !(webhook_url.is_empty() && webhook_key.is_empty()) { - let payload = format!("{{\"{}\":\"{}\"}}", &webhook_key, &msg0); - notify_webhook(&webhook_url, &payload).await; - } - // Send apprise - if !apprise_url.is_empty() { - let payload = format!( - "{{\"title\":\"Docker-Autoheal\",\"body\":\"{}\"}}", - &msg0 - ); - notify_webhook(&apprise_url, &payload).await; - } + msg0 } Err(e) => { // Log result @@ -122,20 +111,20 @@ pub async fn start_loop( name, id, e ); log_message(&msg0, ERROR).await; - // Send webhook - if !(webhook_url.is_empty() && webhook_key.is_empty()) { - let payload = format!("{{\"{}\":\"{}\"}}", &webhook_key, &msg0); - notify_webhook(&webhook_url, &payload).await; - } - // Send apprise - if !apprise_url.is_empty() { - let payload = format!( - "{{\"title\":\"Docker-Autoheal\",\"body\":\"{}\"}}", - &msg0 - ); - notify_webhook(&apprise_url, &payload).await; - } + msg0 } + }; + + // Send webhook + if !(webhook_url.is_empty() && webhook_key.is_empty()) { + let payload = format!("{{\"{}\":\"{}\"}}", &webhook_key, &msg); + notify_webhook(&webhook_url, &payload).await; + } + // Send apprise + if !apprise_url.is_empty() { + let payload = + format!("{{\"title\":\"Docker-Autoheal\",\"body\":\"{}\"}}", &msg); + notify_webhook(&apprise_url, &payload).await; } } }