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.
nu-scripts/lib/dockerhub.nu

19 lines
572 B
Plaintext

export def get_image_digest [image: string, tag: string] {
let token = ( get_token $image )
mut headers = ( []
| append [Accept "application/vnd.docker.distribution.manifest.v2+json"]
| append [Authorization $"Bearer ($token)"]
)
( http get -H $headers $"https://registry.hub.docker.com/v2/($image)/manifests/($tag)"
| from json
| get config
| get digest
| split row ":"
| get 1
)
}
def get_token [image: string] {
http get $"https://auth.docker.io/token?scope=repository:($image):pull&service=registry.docker.io" | get token
}