digitalocean / digitalocean/packer-plugin-digitalocean
Wrong name of base images (type=distribution) retrieved by datasource
- Dominant language
- Go
- Stars
- 27
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
#### Overview of the Issue
I can't retrieve the latest version of a base image using the `digitalocean-image` datasource because the name field of those images only have the version, not the name.
#### Reproduction Steps
The following code is getting the error `Error: Datasource.Execute failed: No matching image found`:
```hcl
data "digitalocean-image" "main" {
name_regex = "debian.*"
type = "distribution"
region = var.region
latest = true
}
```
It looks like the field `name` only contains the _version_ and the _arch_ of the image on those of type `base` (or `distribution`, according to this datasource).
This is a response to get the images from the DigitalOcean API:
```bash
curl -H "Content-Type: application/json" -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" "https://api.digitalocean.com/v2/images?page=1&per_page=1000" | jq
```
Result of that command (I removed redundant parts to keep it small):
```json
{
"images": [
{
"id": 112379295,
"name": "Convoy 0.6.0 on Ubuntu 20.04",
"distribution": "Ubuntu",
"slug": "convoy",
"public": false,
"type": "application",
...
},
{
"id": 112929454,
"name": "20.04 (LTS) x64",
"distribution": "Ubuntu",
"slug": "ubuntu-20-04-x64",
"public": true,
"type": "base",
...
},
{
"id": 113137715,
"name": "Nakama 3.12.0 on Ubuntu 18.04",
"distribution": "Ubuntu",
"slug": "nakama-18-04",
"public": false,
"type": "application",
...
},
{
"id": 114133748,
"name": "Odoo 14 on Ubuntu 20.04",
"distribution": "Ubuntu",
"slug": "bigcloud-odoo",
"public": false,
"type": "application",
...
},
{
"id": 114445163,
"name": "RStudio 2021.09.2+382 on Ubuntu 20.04",
"distribution": "Ubuntu",
"slug": "rstudio-20-04",
"public": false,
"type": "application",
...
},
{
"id": 168639152,
"name": "11 x64",
"distribution": "Debian",
"slug": "debian-11-x64",
"public": true,
"type": "base",
}
...
```
Note that images with `type=base` only has a version on the `name` field, so I can't get (for example) the latest Debian image because the datasource only get images based on the `name` field (and there is no "debian" or any other name there)
### Plugin and Packer version
Packer: v1.12.0
Plugin: packer-plugin-digitalocean_v1.4.1_x5.0_linux_amd64
### Operating system and Environment details
OS: I'm using the latest Packer version from the official Packer Docker container, based on Alpine: https://hub.docker.com/layers/hashicorp/packer/1.12/images/sha256-120faa4b376acc849f0cb19c7847cdccf49a78fd7ee1e2dbb992601e33d4b746
### Log Fragments and crash.log files
Build log with `PACKER_LOG=1`:
```
2025/02/16 13:47:28 [INFO] Packer version: 1.12.0 [go1.22.9 linux amd64]
2025/02/16 13:47:28 Detected config directory from env var: /app/.packer
2025/02/16 13:47:28 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2025/02/16 13:47:28 Detected config directory from env var: /app/.packer
2025/02/16 13:47:28 [INFO] PACKER_CONFIG env var set; attempting to open config file: /app/.packer/.packerconfig
2025/02/16 13:47:28 [WARN] Config file doesn't exist: /app/.packer/.packerconfig
2025/02/16 13:47:28 Detected config directory from env var: /app/.packer
2025/02/16 13:47:28 [INFO] Setting cache directory: /root/.cache/packer
2025/02/16 13:47:28 Detected config directory from env var: /app/.packer
e: Running in background, not using a TTY
2025/02/16 13:47:28 [TRACE] listing potential installations for "github.com/hashicorp/docker" that match "1.1.1". plugingetter.ListInstallationsOptions{PluginDirectory:"/app/.packer/.packer.d/plugins", Bina
ryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linux", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type
:"sha256", Hash:(*sha256.digest)(0xc00098c400)}}, ReleasesOnly:false}}
2025/02/16 13:47:30 [TRACE] Found the following "github.com/hashicorp/docker" installations: [{/app/.packer/.packer.d/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.1.1_x5.0_linux_amd64 v1.1.1
x5.0}]
2025/02/16 13:47:31 [INFO] found external [-packer-default-plugin-name-] builders from docker plugin
2025/02/16 13:47:31 [INFO] found external [import push save tag] post-processors from docker plugin
2025/02/16 13:47:31 plugin "/app/.packer/.packer.d/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.1.1_x5.0_linux_amd64" does not support Protobuf, forcing use of Gob
2025/02/16 13:47:31 [TRACE] listing potential installations for "github.com/digitalocean/digitalocean" that match "1.4.1". plugingetter.ListInstallationsOptions{PluginDirectory:"/app/.packer/.packer.d/plugi
ns", BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linux", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksu
mmer{Type:"sha256", Hash:(*sha256.digest)(0xc00098c400)}}, ReleasesOnly:false}}
2025/02/16 13:47:33 [TRACE] Found the following "github.com/digitalocean/digitalocean" installations: [{/app/.packer/.packer.d/plugins/github.com/digitalocean/digitalocean/packer-plugin-digitalocean_v1.4.1_
x5.0_linux_amd64 v1.4.1 x5.0}]
2025/02/16 13:47:34 [INFO] found external [-packer-default-plugin-name-] builders from digitalocean plugin
2025/02/16 13:47:34 [INFO] found external [import] post-processors from digitalocean plugin
2025/02/16 13:47:34 found external [image] datasource from digitalocean plugin
2025/02/16 13:47:34 [TRACE] listing potential installations for that match "". plugingetter.ListInstallationsOptions{PluginDirectory:"/app/.packer/.packer.d/plugins", BinaryInstallationOptions:pluging
etter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linux", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.dige
st)(0xc00098c900)}}, ReleasesOnly:false}}
2025/02/16 13:47:39 [INFO] found external [-packer-default-plugin-name-] builders from digitalocean plugin
2025/02/16 13:47:39 [INFO] found external [import] post-processors from digitalocean plugin
2025/02/16 13:47:39 found external [image] datasource from digitalocean plugin
2025/02/16 13:47:40 [INFO] found external [-packer-default-plugin-name-] builders from docker plugin
2025/02/16 13:47:40 [INFO] found external [import push save tag] post-processors from docker plugin
2025/02/16 13:47:40 [TRACE] validateValue: not active for project_name, so skipping
2025/02/16 13:47:40 [TRACE] validateValue: not active for project_name_normalized, so skipping
2025/02/16 13:47:40 [TRACE] validateValue: not active for region, so skipping
2025/02/16 13:47:40 [TRACE] validateValue: not active for project_repository, so skipping
2025/02/16 13:47:40 [INFO] Starting external plugin /app/.packer/.packer.d/plugins/github.com/digitalocean/digitalocean/packer-plugin-digitalocean_v1.4.1_x5.0_linux_amd64 start datasource image
2025/02/16 13:47:40 Starting plugin: /app/.packer/.packer.d/plugins/github.com/digitalocean/digitalocean/packer-plugin-digitalocean_v1.4.1_x5.0_linux_amd64 []string{"/app/.packer/.packer.d/plugins/github.co
m/digitalocean/digitalocean/packer-plugin-digitalocean_v1.4.1_x5.0_linux_amd64", "start", "datasource", "image"}
2025/02/16 13:47:40 Waiting for RPC address for: /app/.packer/.packer.d/plugins/github.com/digitalocean/digitalocean/packer-plugin-digitalocean_v1.4.1_x5.0_linux_amd64
2025/02/16 13:47:41 packer-plugin-digitalocean_v1.4.1_x5.0_linux_amd64 plugin: 2025/02/16 13:47:41 Plugin address: unix /tmp/packer-plugin578451918
2025/02/16 13:47:41 packer-plugin-digitalocean_v1.4.1_x5.0_linux_amd64 plugin: 2025/02/16 13:47:41 Waiting for connection...
2025/02/16 13:47:41 Received unix RPC address for /app/.packer/.packer.d/plugins/github.com/digitalocean/digitalocean/packer-plugin-digitalocean_v1.4.1_x5.0_linux_amd64: addr is /tmp/packer-plugin578451918
2025/02/16 13:47:41 packer-plugin-digitalocean_v1.4.1_x5.0_linux_amd64 plugin: 2025/02/16 13:47:41 Serving a plugin connection...
2025/02/16 13:47:41 packer-plugin-digitalocean_v1.4.1_x5.0_linux_amd64 plugin: 2025/02/16 13:47:41 [TRACE] starting datasource image
2025/02/16 13:47:41 [DEBUG] - common: receiving ConfigSpec as gob
2025/02/16 13:47:41 [DEBUG] - common: receiving ConfigSpec as gob
2025/02/16 13:47:41 [INFO] (telemetry) Starting datasource digitalocean-image
2025/02/16 13:47:41 packer-plugin-digitalocean_v1.4.1_x5.0_linux_amd64 plugin: 2025/02/16 13:47:41 [DEBUG] GET https://api.digitalocean.com/v2/images?page=1&per_page=200&type=distribution
2025/02/16 13:47:41 [INFO] (telemetry) ending digitalocean-image
on template/sources.pkr.hcl line 27:
(source code not available)
2025/02/16 13:47:41 [INFO] (telemetry) Finalizing.
Error: Datasource.Execute failed: No matching image found
on template/sources.pkr.hcl line 27:
(source code not available)
2025/02/16 13:47:42 waiting for all plugin processes to complete...
2025/02/16 13:47:42 /app/.packer/.packer.d/plugins/github.com/digitalocean/digitalocean/packer-plugin-digitalocean_v1.4.1_x5.0_linux_amd64: plugin process exited
```
Contributor guide
Research direction
Start by inspecting the digitalocean-image datasource handling of the /v2/images request and name_regex matching, using the template/sources.pkr.hcl reproduction and the documented type=distribution response. Done means the Debian example resolves the latest matching distribution image instead of reporting “No matching image found,” with the corrected behavior covered by a test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100