diff --git a/datasource/image/data.go b/datasource/image/data.go index ead2bc2..a84f37e 100644 --- a/datasource/image/data.go +++ b/datasource/image/data.go @@ -256,7 +256,7 @@ func filterImages(c *Config, images []godo.Image) (godo.Image, error) { return godo.Image{}, fmt.Errorf("More than one matching image found: %v", result) } if len(result) == 0 { - return godo.Image{}, errors.New("No image matching found") + return godo.Image{}, errors.New("No matching image found") } return result[0], nil diff --git a/docs/datasources/digitalocean-image.mdx b/docs/datasources/digitalocean-image.mdx index cc9d7fe..189af60 100644 --- a/docs/datasources/digitalocean-image.mdx +++ b/docs/datasources/digitalocean-image.mdx @@ -26,9 +26,14 @@ for use as a builder source. ## Example Usage +In this example, we combine `name_regex` and `latest` to find the most recent +user generated image matching the name `golden-image-.*`. The ID of the found +image is then passed to the builder where it is used as the base for creating +a new image. + ```hcl data "digitalocean-image" "example" { - name_regex = "golden-image-2022.*" + name_regex = "golden-image-.*" region = "nyc3" type = "user" latest = true @@ -39,7 +44,7 @@ locals { } source "digitalocean" "example" { - snapshot_name = "updated-golden-image" + snapshot_name = "golden-image-{{isotime}}" image = local.image_id region = "nyc3" size = "s-1vcpu-1gb"