Skip to content

Commit

Permalink
Merge pull request #71 from tmknight/dev/0.8.0
Browse files Browse the repository at this point in the history
v0.8.0
  • Loading branch information
tmknight authored Jan 30, 2024
2 parents c79b3f4 + b73b799 commit 295cbb8
Show file tree
Hide file tree
Showing 14 changed files with 381 additions and 222 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ jobs:

# Setup QEMU for multi-arch
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
with:
platforms: amd64,arm64

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
id: container-registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand All @@ -70,12 +70,12 @@ jobs:
- name: Log into Docker Hub
id: docker-hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
Expand All @@ -94,7 +94,7 @@ jobs:
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: ${{ env.CONTEXT }}
platforms: linux/amd64,linux/arm64
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
workflow_run:
workflows: ["Github Tag"]
types: [completed]
# branches: [main]

env:
# Use docker.io for Docker Hub if empty
Expand All @@ -16,8 +15,6 @@ env:
IMAGE: docker-autoheal
# github.repository as <account>/<repo>
IMAGE_NAME: tmknight/docker-autoheal
# cosign version
COSIGN_VER: 'v2.1.1'
# Build args
CONTEXT: .
DISTRO: alpine
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/github-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@ name: "Github Tag"

on:
workflow_dispatch:
# push:
# paths-ignore:
# - '.github/**'
# - 'examples/**'
# - 'docker/**'
# - 'test/**'
# - '*.md'
# - '.*'
# - '*.lock'
# - '.LICENSE'
# branches: [ "main", "develop" ]
pull_request:
types: [closed]
branches: [main]
Expand Down
19 changes: 17 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
# Changelog

All notable changes to docker-autoheal are documented in this file.
The sections should follow the order `Packaging`, `Added`, `Changed`, `Fixed` and `Removed`.
The sections should follow the order `Security`, `Added`, `Changed`, `Fixed`, and `Removed`.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

## 0.8.0

### Added

- Binary option for `tcp-timeout`, now in alignment with environment `AUTOHEAL_TCP_TIMEOUT`
- Breaking changes
- `stop-timeout` is now `s`
- `tcp-timeout` is now `t`
- Additional checks, balances & error handling

### Changed

- Refactored binary options into separate function for more efficient parsing
- Refactored environment variables into separate function for better organization

## 0.7.0

### Added
Expand All @@ -17,7 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

### Fixed

- Corrected binary options descriptions and hints for webhook entries
- Binary options descriptions and hints for webhook entries

## 0.6.0

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.7.0"
version = "0.8.0"
authors = ["Travis M Knight"]
license = "MIT"
description = "A cross-platform tool to monitor and remediate unhealthy Docker containers"
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Options:
One of local, socket, http, or ssl
-l, --container-label <CONTAINER_LABEL>
Container label to monitor (e.g. autoheal)
-t, --stop-timeout <STOP_TIMEOUT>
-s, --stop-timeout <STOP_TIMEOUT>
Time in seconds to wait for action to complete
-i, --interval <INTERVAL>
Time in seconds to check health
Expand All @@ -62,6 +62,8 @@ Options:
-p, --tcp-port <TCP_PORT>
The tcp port number of the Docker host (when -c http
or ssl)
-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>
Expand Down
40 changes: 20 additions & 20 deletions src/execute/connect.rs
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
use crate::{report::logging::log_message, ERROR, INFO};
use crate::{log_message, ERROR, INFO};
use bollard::{Docker, API_DEFAULT_VERSION};

pub async fn connect_docker(
autoheal_connection_type: String,
autoheal_tcp_address: String,
autoheal_tcp_timeout: u64,
autoheal_key_path: String,
autoheal_cert_path: String,
autoheal_ca_path: String,
connection_type: String,
tcp_address: String,
tcp_timeout: u64,
key_path: String,
cert_path: String,
ca_path: String,
) -> Docker {
// Log final connection paramaters
let msg0 = format!("Monitoring Docker via {}", autoheal_connection_type);
let msg0 = format!("Monitoring Docker via {}", connection_type);
log_message(&msg0, INFO).await;
match autoheal_connection_type.as_str() {
match connection_type.as_str() {
"http" => {
let msg1 = format!("Connecting to {}", autoheal_tcp_address);
let msg1 = format!("Connecting to {}", tcp_address);
log_message(&msg1, INFO).await;
}
"ssl" => {
let msg1 = format!("Connecting to {}", autoheal_tcp_address);
let msg1 = format!("Connecting to {}", tcp_address);
log_message(&msg1, INFO).await;
let msg2 = format!(
"Certificate information: {}, {}, {}",
autoheal_key_path, autoheal_cert_path, autoheal_ca_path
key_path, cert_path, ca_path
);
log_message(&msg2, INFO).await;
}
&_ => {}
}
// Connect to Docker as specified
let docker = match autoheal_connection_type.as_str() {
let docker = match connection_type.as_str() {
"http" => Docker::connect_with_http(
&autoheal_tcp_address,
autoheal_tcp_timeout,
&tcp_address,
tcp_timeout,
API_DEFAULT_VERSION,
),
"socket" => Docker::connect_with_socket_defaults(),
"ssl" => Docker::connect_with_ssl(
&autoheal_tcp_address,
std::path::Path::new(&autoheal_key_path),
std::path::Path::new(&autoheal_cert_path),
std::path::Path::new(&autoheal_ca_path),
autoheal_tcp_timeout,
&tcp_address,
std::path::Path::new(&key_path),
std::path::Path::new(&cert_path),
std::path::Path::new(&ca_path),
tcp_timeout,
API_DEFAULT_VERSION,
),
&_ => Docker::connect_with_local_defaults(),
Expand Down
10 changes: 4 additions & 6 deletions src/execute/looper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ pub async fn start_loop(
// Determine if stop override label
let s = "autoheal.stop.timeout".to_string();
let autoheal_stop_timeout: isize = match container.labels {
Some(label) => {
match label.get(&s) {
Some(v) => v.parse().unwrap_or(autoheal_stop_timeout),
None => autoheal_stop_timeout,
}
}
Some(label) => match label.get(&s) {
Some(v) => v.parse().unwrap_or(autoheal_stop_timeout),
None => autoheal_stop_timeout,
},
None => autoheal_stop_timeout,
};

Expand Down
Loading

0 comments on commit 295cbb8

Please sign in to comment.