mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2025-12-20 22:59:42 -05:00
feat: Add image_id attribute to docker_image resource. (#450)
This commit is contained in:
parent
b37b866b6d
commit
ad65027896
3 changed files with 14 additions and 1 deletions
|
|
@ -94,7 +94,8 @@ resource "docker_image" "zoo" {
|
|||
|
||||
### Read-Only
|
||||
|
||||
- `id` (String) The ID of this resource.
|
||||
- `id` (String) Unique identifier for this resource. This is not the image ID, but the ID of the resource in the Terraform state. This is used to identify the resource in the Terraform state. To reference the correct image ID, use the `image_id` attribute.
|
||||
- `image_id` (String) The ID of the image (as seen when executing `docker inspect` on the image). Can be used to reference the image via its ID in other resources.
|
||||
- `latest` (String, Deprecated) The ID of the image in the form of `sha256:<hash>` image digest. Do not confuse it with the default `latest` tag.
|
||||
- `output` (String, Deprecated)
|
||||
- `repo_digest` (String) The image sha256 digest in the form of `repo[:tag]@sha256:<hash>`.
|
||||
|
|
|
|||
|
|
@ -14,6 +14,11 @@ func resourceDockerImage() *schema.Resource {
|
|||
DeleteContext: resourceDockerImageDelete,
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Unique identifier for this resource. This is not the image ID, but the ID of the resource in the Terraform state. This is used to identify the resource in the Terraform state. To reference the correct image ID, use the `image_id` attribute.",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Description: "The name of the Docker image, including any tags or SHA256 repo digests.",
|
||||
|
|
@ -28,6 +33,12 @@ func resourceDockerImage() *schema.Resource {
|
|||
Deprecated: "Use repo_digest instead",
|
||||
},
|
||||
|
||||
"image_id": {
|
||||
Type: schema.TypeString,
|
||||
Description: "The ID of the image (as seen when executing `docker inspect` on the image). Can be used to reference the image via its ID in other resources.",
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"repo_digest": {
|
||||
Type: schema.TypeString,
|
||||
Description: "The image sha256 digest in the form of `repo[:tag]@sha256:<hash>`.",
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ func resourceDockerImageRead(ctx context.Context, d *schema.ResourceData, meta i
|
|||
|
||||
// TODO mavogel: remove the appended name from the ID
|
||||
d.SetId(foundImage.ID + d.Get("name").(string))
|
||||
d.Set("image_id", foundImage.ID)
|
||||
d.Set("latest", foundImage.ID)
|
||||
d.Set("repo_digest", repoDigest)
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue