Add support for tags

main
trivernis 1 year ago
parent 895385f218
commit ce0343c384
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,4 +1,4 @@
export def get_image_digest [image: string] { export def get_image_digest [image: string, tag: string] {
let token = ( get_token $image ) let token = ( get_token $image )
mut headers = ( [] mut headers = ( []
| append [Accept "application/vnd.docker.distribution.manifest.v2+json"] | append [Accept "application/vnd.docker.distribution.manifest.v2+json"]
@ -6,7 +6,7 @@ export def get_image_digest [image: string] {
) )
print $headers print $headers
( http get -H $headers $"https://registry.hub.docker.com/v2/($image)/manifests/latest" ( http get -H $headers $"https://registry.hub.docker.com/v2/($image)/manifests/($tag)"
| from json | from json
| get config | get config
| get digest | get digest

@ -29,12 +29,18 @@ export def needs_update [] {
let data = $in let data = $in
let name_parts = ( $data.Name | split row "/" --number 2 ) let name_parts = ( $data.Name | split row "/" --number 2 )
let registry = ( $name_parts | first ) let registry = ( $name_parts | first )
let image = ( $name_parts | last | split row ":" | get 0 ) let img_parts = ( $name_parts | last | split row ":" )
let image = ( $img_parts | get 0 )
let tag = ( $img_parts | get 1 )
let digest = $data.Id let digest = $data.Id
print $"Checking if ($image) has updates on ($registry)" print $"Checking if ($image):($tag) has updates on ($registry)"
if $registry == "docker.io" { if $registry == "docker.io" {
( dockerhub get_image_digest $image ) != $digest try {
( dockerhub get_image_digest $image $tag ) != $digest
} catch {
false
}
} else { } else {
print $"Host ($registry) is not supported" print $"Host ($registry) is not supported"
false false

Loading…
Cancel
Save