diff --git a/CHANGELOG.md b/CHANGELOG.md index d0247f3..d378d54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ## [Unreleased] +## 0.10.1 + +### Changed + +- Binary options + - -v, --version replaced by -V, --version to be in alignment with standard practices + - Alphabetized help output for easier reading (lowercase then uppercase) + +### Fixed + +- Binary options + - -a, --post-action replaced by -P, --post-action to resolve conflict with -a, --apprise-url + ## 0.10.0 There are several breaking changes; please read carefully and refer to [README](https://github.com/tmknight/docker-autoheal/blob/main/README.md) for more details @@ -21,7 +34,7 @@ There are several breaking changes; please read carefully and refer to [README]( - autoheal.monitor.enable (TRUE/FALSE) to control monitoring of individual containers - Overrides AUTOHEAL_MONITOR_ALL - Returning last health 'ExitCode` and 'Output' to log (and webhook/apprise if configured) for unhealthy containers - + ### Changed - Binary options diff --git a/Cargo.lock b/Cargo.lock index 36cb87f..2392506 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,7 +188,7 @@ dependencies = [ [[package]] name = "docker-autoheal" -version = "0.10.0" +version = "0.10.1" dependencies = [ "bollard", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 135ff9b..6c49943 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "docker-autoheal" -version = "0.10.0" +version = "0.10.1" authors = ["Travis M Knight"] license = "GPL-3.0" description = "A cross-platform tool to monitor and remediate unhealthy Docker containers" diff --git a/README.md b/README.md index 049a79d..e54d29b 100644 --- a/README.md +++ b/README.md @@ -51,39 +51,39 @@ Used when executed in native OS (NOTE: The environment variables are also accept ```bash Options: + -a, --apprise-url + The apprise url -c, --connection-type One of local, socket, http, or ssl - -s, --stop-timeout - Time in seconds to wait for action to complete - -i, --interval - Time in seconds to check health -d, --start-delay Time in seconds to wait for first check + -h, --help Print help + -i, --interval + Time in seconds to check health + -j, --webhook-key + The webhook json key string + -k, --key-path + The fully qualified path to requisite ssl PEM files + -l, --log-all Enable logging of unhealthy containers where restart + is disabled (WARNING, this could be chatty) + -m, --monitor-all Enable monitoring off all containers that have a + healthcheck -n, --tcp-host The hostname or IP address of the Docker host (when -c http or ssl) -p, --tcp-port The tcp port number of the Docker host (when -c http or ssl) + -s, --stop-timeout + Time in seconds to wait for action to complete -t, --tcp-timeout Time in seconds to wait for connection to complete - -k, --key-path - The fully qualified path to requisite ssl PEM files - -a, --apprise-url - The apprise url - -j, --webhook-key - The webhook json key string -w, --webhook-url The webhook url - -a, --post-action + -P, --post-action The absolute path to a script that should be executed after container restart - -m, --monitor-all Enable monitoring off all containers that have a - healthcheck - -l, --log-all Enable logging of unhealthy containers where restart - is disabled (WARNING, this could be chatty) - -h, --help Print help - -v, --version Print version information + -V, --version Print version information ``` ### Local diff --git a/src/inquire/options.rs b/src/inquire/options.rs index 4627a94..2aa29f4 100644 --- a/src/inquire/options.rs +++ b/src/inquire/options.rs @@ -2,20 +2,20 @@ use crate::{report::logging::print_version, ALLOWED_CONNECTION_TYPES}; use getopts::Options; pub struct OptionsList { + pub apprise_url: Option, pub connection_type: Option, - pub stop_timeout: Option, - pub interval: Option, pub start_delay: Option, + pub interval: Option, + pub webhook_key: Option, + pub key_path: Option, + pub log_all: bool, + pub monitor_all: bool, pub tcp_host: Option, pub tcp_port: Option, + pub stop_timeout: Option, pub tcp_timeout: Option, - pub key_path: Option, - pub apprise_url: Option, - pub webhook_key: Option, pub webhook_url: Option, pub post_action: Option, - pub log_all: bool, - pub monitor_all: bool, } pub fn get_opts(args: Vec) -> OptionsList { @@ -23,6 +23,7 @@ pub fn get_opts(args: Vec) -> OptionsList { // Establish usable arguments let mut opts = Options::new(); + opts.optopt("a", "apprise-url", "The apprise url", ""); opts.optopt( "c", "connection-type", @@ -30,11 +31,12 @@ pub fn get_opts(args: Vec) -> OptionsList { "", ); opts.optopt( - "s", - "stop-timeout", - "Time in seconds to wait for action to complete", - "", + "d", + "start-delay", + "Time in seconds to wait for first check", + "", ); + opts.optflag("h", "help", "Print help"); opts.optopt( "i", "interval", @@ -42,10 +44,26 @@ pub fn get_opts(args: Vec) -> OptionsList { "", ); opts.optopt( - "d", - "start-delay", - "Time in seconds to wait for first check", - "", + "j", + "webhook-key", + "The webhook json key string", + "", + ); + opts.optopt( + "k", + "key-path", + "The fully qualified path to requisite ssl PEM files", + "", + ); + opts.optflag( + "l", + "log-all", + "Enable logging of unhealthy containers where restart is disabled (WARNING, this could be chatty)", + ); + opts.optflag( + "m", + "monitor-all", + "Enable monitoring off all containers that have a healthcheck", ); opts.optopt( "n", @@ -59,44 +77,26 @@ pub fn get_opts(args: Vec) -> OptionsList { "The tcp port number of the Docker host (when -c http or ssl)", "", ); + opts.optopt( + "s", + "stop-timeout", + "Time in seconds to wait for action to complete", + "", + ); opts.optopt( "t", "tcp-timeout", "Time in seconds to wait for connection to complete", "", ); - opts.optopt( - "k", - "key-path", - "The fully qualified path to requisite ssl PEM files", - "", - ); - opts.optopt("a", "apprise-url", "The apprise url", ""); - opts.optopt( - "j", - "webhook-key", - "The webhook json key string", - "", - ); opts.optopt("w", "webhook-url", "The webhook url", ""); opts.optopt( - "a", + "P", "post-action", "The absolute path to a script that should be executed after container restart", "", ); - opts.optflag( - "m", - "monitor-all", - "Enable monitoring off all containers that have a healthcheck", - ); - opts.optflag( - "l", - "log-all", - "Enable logging of unhealthy containers where restart is disabled (WARNING, this could be chatty)", - ); - opts.optflag("h", "help", "Print help"); - opts.optflag("v", "version", "Print version information"); + opts.optflag("V", "version", "Print version information"); let matches = match opts.parse(&args[1..]) { Ok(m) => m, @@ -108,7 +108,7 @@ pub fn get_opts(args: Vec) -> OptionsList { }; // Process matching arguments - if matches.opt_present("v") { + if matches.opt_present("V") { print_version(); std::process::exit(0); } else if matches.opt_present("h") { @@ -133,19 +133,19 @@ pub fn get_opts(args: Vec) -> OptionsList { }; OptionsList { + apprise_url: matches.opt_str("a"), connection_type: matches.opt_str("c"), - stop_timeout: matches.opt_str("s"), - interval: matches.opt_str("i"), start_delay: matches.opt_str("d"), + interval: matches.opt_str("i"), + webhook_key: matches.opt_str("j"), + key_path: matches.opt_str("k"), + log_all: matches.opt_present("l"), + monitor_all: matches.opt_present("m"), tcp_host: matches.opt_str("n"), tcp_port: matches.opt_str("p"), + stop_timeout: matches.opt_str("s"), tcp_timeout: matches.opt_str("t"), - key_path: matches.opt_str("k"), - apprise_url: matches.opt_str("a"), - webhook_key: matches.opt_str("j"), webhook_url: matches.opt_str("w"), - post_action: matches.opt_str("a"), - log_all: matches.opt_present("l"), - monitor_all: matches.opt_present("m"), + post_action: matches.opt_str("P"), } }