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

18 lines
544 B
Plaintext

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