-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(registry): add tag data source #2696
Conversation
Hello and thanks a lot for contributing :) I got some questions:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2696 +/- ##
==========================================
- Coverage 71.43% 71.12% -0.32%
==========================================
Files 277 338 +61
Lines 35875 33960 -1915
==========================================
- Hits 25628 24154 -1474
+ Misses 8028 7463 -565
- Partials 2219 2343 +124 ☔ View full report in Codecov by Sentry. |
Hi @remyleone ! The idea behind this is to retrieve the digest of an image. It can help in invalidating ressources on image updates even though the tag has not changed. Some provider handle this for "latest" tags, but some control and flexibility is nice. If I'm not mistaken the docker provider you mentioned needs a docker daemon to run, which adds some complexity... You can use tf to setup a scw instance, install docker on it, then run another terraform plan which will connect to it and pull the image data... There are simpler ways to do it but since most of my tf plans are using this scw provider I thought it be simpler. Do you have some specific concerns? |
@remyleone Here is the workaround I'm currently using terraform {
required_version = "1.9.4"
required_providers {
http = {
source = "hashicorp/http"
version = "3.4.4"
}
}
}
variable "region" {
description = "Region of the image to retrieve"
type = string
default = "fr-par"
}
variable "scw_secret" {
description = "Scaleway Secret"
type = string
sensitive = true
}
variable "tag" {
description = "Tag of the image to retrieve"
type = string
default = "latest"
}
variable "image_id" {
description = "id of the image to retrieve"
type = string
}
data "http" "registry_tags" {
url = "https://api.scaleway.com/registry/v1/regions/${var.region}/images/${var.image_id}/tags?name=${var.tag}"
request_headers = {
"X-Auth-Token" = var.scw_secret
}
# {
# "tags": [
# {
# "id": "string",
# "name": "string",
# "image_id": "string",
# "status": "string",
# "digest": "string",
# "created_at": "string",
# "updated_at": "string"
# }
# ],
# "total_count": "integer"
# }
}
output "image_id" {
value = var.image_id
}
output "tag_id" {
value = jsondecode(data.http.registry_tags.response_body).tags[0].id
}
output "tag_sha" {
value = jsondecode(data.http.registry_tags.response_body).tags[0].digest
} |
Ok I understand better your use case. I think documentation and tests are missing from this PR and we would need it to merge it. Otherwise this PR looks good :) thanks a lot for contributing :) |
@remyleone Thanks! Will you handle docs and tests? btw force pushed to rebase main and keep this branch up to date |
No description provided.