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.
24 lines
731 B
Plaintext
24 lines
731 B
Plaintext
#!/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
|
|
} |