Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add apprise type and additional error notification #118

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions shepherd
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ update_services() {

if ! DOCKER_CLI_EXPERIMENTAL=enabled docker "${config_flag[@]}" manifest inspect $insecure_registry_flag "$image" > /dev/null; then
logger "Error updating service $name! Image $image does not exist or it is not available"
if [[ "$apprise_sidecar_url" != "" ]]; then
title="[Shepherd] Error updating service $name"
body="$(date) Service $name Image $image does not exist or it is not available"
curl -X POST -H "Content-Type: application/json" --data "{\"title\": \"$title\", \"body\": \"$body\", \"type\": \"failure\"}" "$apprise_sidecar_url"
fi
else
logger "Trying to update service $name with image $image" "true"

Expand All @@ -113,7 +118,7 @@ update_services() {
if [[ "$apprise_sidecar_url" != "" ]]; then
title="[Shepherd] Service $name update failed on $hostname"
body="$(date) Service $name failed to update to $(docker service inspect "$name" -f '{{.Spec.TaskTemplate.ContainerSpec.Image}}')"
curl -X POST -H "Content-Type: application/json" --data "{\"title\": \"$title\", \"body\": \"$body\"}" "$apprise_sidecar_url"
curl -X POST -H "Content-Type: application/json" --data "{\"title\": \"$title\", \"body\": \"$body\", \"type\": \"failure\"}" "$apprise_sidecar_url"
fi
continue # continue with next service
fi
Expand All @@ -128,7 +133,7 @@ update_services() {
if [[ "$apprise_sidecar_url" != "" ]]; then
title="[Shepherd] Service $name updated on $hostname"
body="$(date) Service $name was updated from $previous_image to $current_image"
curl -X POST -H "Content-Type: application/json" --data "{\"title\": \"$title\", \"body\": \"$body\"}" "$apprise_sidecar_url"
curl -X POST -H "Content-Type: application/json" --data "{\"title\": \"$title\", \"body\": \"$body\", \"type\": \"success\"}" "$apprise_sidecar_url"
fi

if [[ "$image_autoclean_limit" != "" ]]; then
Expand Down