Skip to content

Commit ebbbda9

Browse files
committed
feat: support numeric image IDs for snapshots
GetByNameAndArchitecture only works for named images. Hetzner snapshots have no name — only a numeric ID. If DISK_IMAGE is a numeric string, look up by ID directly using Image.GetByID. Otherwise fall back to the existing name+architecture lookup. This allows users to boot DevPod workspaces from a pre-baked Hetzner snapshot, skipping slow provisioning steps.
1 parent 5af4afd commit ebbbda9

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

pkg/hetzner/hetzner.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,19 @@ func (h *Hetzner) BuildServerOptions(
143143
// Machines starting "cax" are ARM64
144144
arch = hcloud.ArchitectureARM
145145
}
146-
image, _, err := h.client.Image.GetByNameAndArchitecture(ctx, opts.DiskImage, arch)
147-
if err != nil {
148-
return nil, nil, nil, err
146+
147+
var image *hcloud.Image
148+
if id, err := strconv.Atoi(opts.DiskImage); err == nil {
149+
// Numeric ID — look up directly (supports snapshots, which have no name)
150+
image, _, err = h.client.Image.GetByID(ctx, id)
151+
if err != nil {
152+
return nil, nil, nil, err
153+
}
154+
} else {
155+
image, _, err = h.client.Image.GetByNameAndArchitecture(ctx, opts.DiskImage, arch)
156+
if err != nil {
157+
return nil, nil, nil, err
158+
}
149159
}
150160
if image == nil {
151161
return nil, nil, nil, ErrUnknownDiskImage

0 commit comments

Comments
 (0)