Skip to content

Instantly share code, notes, and snippets.

@rafagsiqueira
Last active November 13, 2020 21:33
Show Gist options
  • Save rafagsiqueira/14700c99aeacbcf1202004e1d49e2b46 to your computer and use it in GitHub Desktop.
Save rafagsiqueira/14700c99aeacbcf1202004e1d49e2b46 to your computer and use it in GitHub Desktop.
data "http" "access_token" {
url = "https://${var.docker_registry.host}/oauth2/token?service=${var.docker_registry.host}&scope=repository:*:pull"
request_headers = {
Authorization = "Basic ${base64encode("${var.docker_registry.user}:${var.docker_registry.password}")}"
}
}
data "http" "tips-admin" {
url = "https://${var.docker_registry.host}/v2/tips-admin/manifests/${local.environment}"
request_headers = {
Accept = "application/vnd.docker.distribution.manifest.v2+json",
Authorization = "Bearer ${jsondecode(data.http.access_token.body).access_token}"
}
}
output "tips-admin" {
value = "${var.docker_registry.host}/tips-admin@${data.http.tips-admin.response_headers.Docker-Content-Digest}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment