List containers using image found as outdated

main
trivernis 1 year ago
parent 5605bc3a12
commit d891eab6f6
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -12,6 +12,11 @@ export def publish [
] { ] {
let cfg = ( config read_file cntfy ) let cfg = ( config read_file cntfy )
if ( $env.NTFY_LIMIT? == 0) {
sleep 5sec
let-env NTFY_LIMIT = 3
}
let request_body = ({ let request_body = ({
topic: $topic topic: $topic
title: $title title: $title

@ -49,9 +49,25 @@ export def needs_update [] {
def print_needs_update [ntfy: bool] { def print_needs_update [ntfy: bool] {
let data = $in let data = $in
print $"Image `($data.Name)` needs to be updated." let containers = ( containers_for_image $data.Name )
print $"Image `($data.Name)` needs to be updated. Used by ($containers | str join ', ')"
if $ntfy { if $ntfy {
cntfy publish --tags [ podman $data.Name ] --priority 4 --title $"($data.Name) outdated" "updates" $"Container ($data.Name) needs to be updated." (
cntfy publish
--tags [ podman $data.Name ]
--priority 4
--title $"($data.Name) outdated"
"updates" $"Container ($data.Name) needs to be updated. Used by ($data.Containers) containers. Used by: ( $containers | str join '\n' )"
)
}
} }
def containers_for_image [image: string] {
( podman container ls --all --format json
| from json
| where Image == $image
| insert Name {|$it| $it.Names? | get 0 }
| get Name
)
} }
Loading…
Cancel
Save