Add implementation to retrieve container information
parent
8509cf2622
commit
eb606a0c17
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/env nu
|
||||||
|
|
||||||
|
export def main [] {
|
||||||
|
get_info "docker.io/itzg/minecraft-server"
|
||||||
|
}
|
||||||
|
|
||||||
|
export def get_info [image_name: string] {
|
||||||
|
let info = ( parse_name $image_name )
|
||||||
|
let token = ( get_token $info.registry $info.group $info.image )
|
||||||
|
http get -H [Authorization $"Bearer ($token)"] $"https://index.($info.registry)/v2/($info.group)/($info.image)/manifests/latest" | from json
|
||||||
|
}
|
||||||
|
|
||||||
|
def parse_name [image_name: string] {
|
||||||
|
let parts = ( $image_name | split row "/" )
|
||||||
|
{
|
||||||
|
registry: $parts.0
|
||||||
|
group: $parts.1
|
||||||
|
image: $parts.2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_token [registry: string, group: string, image: string] {
|
||||||
|
http get $"https://auth.($registry)/token?service=registry.($registry)&scope=repository:($group)/($image):pull" | get token
|
||||||
|
}
|
Loading…
Reference in New Issue