Skip to content

Commit

Permalink
Fix string parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Steeven9 committed Apr 7, 2024
1 parent fa45cbe commit 6b74480
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions shepherd
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,8 @@ authenticate_to_registries() {

send_notification() {
if [[ "$apprise_sidecar_url" != "" ]]; then
status=$(curl -s -X POST -H "Content-Type: application/json" --data "{\"title\": \"$1\", \"body\": \"$2\", \"notify_type\": \"$3\"}" "$apprise_sidecar_url")
if [[ $status = 0 ]]; then
logger "Sent notification"
else
logger "Failed sending notification!"
fi
status=$(curl --no-progress-meter -X POST -H "Content-Type: application/json" --data "{\"title\": \"$1\", \"body\": \"$2\", \"notify_type\": \"$3\"}" "$apprise_sidecar_url")
logger "Sending notification: $status"
fi
}

Expand Down Expand Up @@ -108,7 +104,7 @@ update_services() {

title="[Shepherd] Error updating service $name"
body="$(date) Service $name Image $image does not exist or it is not available"
send_notification $title $body "failure"
send_notification "$title" "$body" "failure"

else
logger "Trying to update service $name with image $image" "true"
Expand All @@ -129,7 +125,7 @@ update_services() {

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}}')"
send_notification $title $body "failure"
send_notification "$title" "$body" "failure"

continue # continue with next service
fi
Expand All @@ -144,7 +140,7 @@ update_services() {

title="[Shepherd] Service $name updated on $hostname"
body="$(date) Service $name was updated from $previous_image to $current_image"
send_notification $title $body "success"
send_notification "$title" "$body" "success"

if [[ "$image_autoclean_limit" != "" ]]; then
logger "Cleaning up old docker images, leaving last $image_autoclean_limit"
Expand Down

0 comments on commit 6b74480

Please sign in to comment.