Skip to content

Commit

Permalink
Merge pull request #84 from tmknight/develop
Browse files Browse the repository at this point in the history
v0.10.1
  • Loading branch information
tmknight authored Feb 21, 2024
2 parents 50e3be1 + 226e361 commit 4e4ab9f
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 70 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
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.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"
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,39 +51,39 @@ Used when executed in native OS (NOTE: The environment variables are also accept

```bash
Options:
-a, --apprise-url <APPRISE_URL>
The apprise url
-c, --connection-type <CONNECTION_TYPE>
One of local, socket, http, or ssl
-s, --stop-timeout <STOP_TIMEOUT>
Time in seconds to wait for action to complete
-i, --interval <INTERVAL>
Time in seconds to check health
-d, --start-delay <START_DELAY>
Time in seconds to wait for first check
-h, --help Print help
-i, --interval <INTERVAL>
Time in seconds to check health
-j, --webhook-key <WEBHOOK_KEY>
The webhook json key string
-k, --key-path <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 <TCP_HOST>
The hostname or IP address of the Docker host (when -c
http or ssl)
-p, --tcp-port <TCP_PORT>
The tcp port number of the Docker host (when -c http
or ssl)
-s, --stop-timeout <STOP_TIMEOUT>
Time in seconds to wait for action to complete
-t, --tcp-timeout <TCP_TIMEOUT>
Time in seconds to wait for connection to complete
-k, --key-path <KEY_PATH>
The fully qualified path to requisite ssl PEM files
-a, --apprise-url <APPRISE_URL>
The apprise url
-j, --webhook-key <WEBHOOK_KEY>
The webhook json key string
-w, --webhook-url <WEBHOOK_URL>
The webhook url
-a, --post-action <SCRIPT_PATH>
-P, --post-action <SCRIPT_PATH>
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
Expand Down
100 changes: 50 additions & 50 deletions src/inquire/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,68 @@ use crate::{report::logging::print_version, ALLOWED_CONNECTION_TYPES};
use getopts::Options;

pub struct OptionsList {
pub apprise_url: Option<String>,
pub connection_type: Option<String>,
pub stop_timeout: Option<String>,
pub interval: Option<String>,
pub start_delay: Option<String>,
pub interval: Option<String>,
pub webhook_key: Option<String>,
pub key_path: Option<String>,
pub log_all: bool,
pub monitor_all: bool,
pub tcp_host: Option<String>,
pub tcp_port: Option<String>,
pub stop_timeout: Option<String>,
pub tcp_timeout: Option<String>,
pub key_path: Option<String>,
pub apprise_url: Option<String>,
pub webhook_key: Option<String>,
pub webhook_url: Option<String>,
pub post_action: Option<String>,
pub log_all: bool,
pub monitor_all: bool,
}

pub fn get_opts(args: Vec<String>) -> OptionsList {
let program = args[0].clone();

// Establish usable arguments
let mut opts = Options::new();
opts.optopt("a", "apprise-url", "The apprise url", "<APPRISE_URL>");
opts.optopt(
"c",
"connection-type",
"One of local, socket, http, or ssl",
"<CONNECTION_TYPE>",
);
opts.optopt(
"s",
"stop-timeout",
"Time in seconds to wait for action to complete",
"<STOP_TIMEOUT>",
"d",
"start-delay",
"Time in seconds to wait for first check",
"<START_DELAY>",
);
opts.optflag("h", "help", "Print help");
opts.optopt(
"i",
"interval",
"Time in seconds to check health",
"<INTERVAL>",
);
opts.optopt(
"d",
"start-delay",
"Time in seconds to wait for first check",
"<START_DELAY>",
"j",
"webhook-key",
"The webhook json key string",
"<WEBHOOK_KEY>",
);
opts.optopt(
"k",
"key-path",
"The fully qualified path to requisite ssl PEM files",
"<KEY_PATH>",
);
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",
Expand All @@ -59,44 +77,26 @@ pub fn get_opts(args: Vec<String>) -> OptionsList {
"The tcp port number of the Docker host (when -c http or ssl)",
"<TCP_PORT>",
);
opts.optopt(
"s",
"stop-timeout",
"Time in seconds to wait for action to complete",
"<STOP_TIMEOUT>",
);
opts.optopt(
"t",
"tcp-timeout",
"Time in seconds to wait for connection to complete",
"<TCP_TIMEOUT>",
);
opts.optopt(
"k",
"key-path",
"The fully qualified path to requisite ssl PEM files",
"<KEY_PATH>",
);
opts.optopt("a", "apprise-url", "The apprise url", "<APPRISE_URL>");
opts.optopt(
"j",
"webhook-key",
"The webhook json key string",
"<WEBHOOK_KEY>",
);
opts.optopt("w", "webhook-url", "The webhook url", "<WEBHOOK_URL>");
opts.optopt(
"a",
"P",
"post-action",
"The absolute path to a script that should be executed after container restart",
"<SCRIPT_PATH>",
);
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,
Expand All @@ -108,7 +108,7 @@ pub fn get_opts(args: Vec<String>) -> 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") {
Expand All @@ -133,19 +133,19 @@ pub fn get_opts(args: Vec<String>) -> 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"),
}
}

0 comments on commit 4e4ab9f

Please sign in to comment.