You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#!/bin/env nu
|
|
|
|
use ./lib/cntfy.nu
|
|
|
|
use ./lib/dockerhub.nu
|
|
|
|
|
|
|
|
def main [
|
|
|
|
--ntfy: bool
|
|
|
|
] {
|
|
|
|
let images = ( get_images )
|
|
|
|
let image_count = ( $images | length )
|
|
|
|
if $image_count == 0 {
|
|
|
|
print "No images found"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
print $"($image_count) local image[s] found"
|
|
|
|
|
|
|
|
( $images
|
|
|
|
| where { |$it| $it.Names? != null }
|
|
|
|
| insert Name {|$it| $it.Names | first }
|
|
|
|
| where {|| needs_update }
|
|
|
|
| each {|| print_needs_update $ntfy }
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
def get_images [] {
|
|
|
|
podman images --no-trunc --format json | from json
|
|
|
|
}
|
|
|
|
|
|
|
|
export def needs_update [] {
|
|
|
|
let data = $in
|
|
|
|
let name_parts = ( $data.Name | split row "/" --number 2 )
|
|
|
|
let host = ( $name_parts | first )
|
|
|
|
let image = ( $name_parts | last | split row ":" | get 0 )
|
|
|
|
let digest = $data.Id
|
|
|
|
|
|
|
|
if $host == "docker.io" {
|
|
|
|
( dockerhub get_image_digest $image ) != $digest
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def print_needs_update [ntfy: bool] {
|
|
|
|
let data = $in
|
|
|
|
print $"Image `($data.Name)` needs to be updated."
|
|
|
|
|
|
|
|
if $ntfy {
|
|
|
|
cntfy publish --tags [ podman $data.Name ] --title $"($data.Name) outdated" "updates" $"Container ($data.Name) needs to be updated."
|
|
|
|
}
|
|
|
|
}
|