mirror of
https://github.com/hashicorp/packer.git
synced 2026-09-26 01:34:00 -04:00
builder/digitalocean: Use correct type for image for Droplet creates.
This commit is contained in:
@@ -3,6 +3,7 @@ package digitalocean
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"io/ioutil"
|
||||
|
||||
@@ -35,13 +36,18 @@ func (s *stepCreateDroplet) Run(ctx context.Context, state multistep.StateBag) m
|
||||
userData = string(contents)
|
||||
}
|
||||
|
||||
createImage := godo.DropletCreateImage{Slug: c.Image}
|
||||
|
||||
imageId, err := strconv.Atoi(c.Image)
|
||||
if err == nil {
|
||||
createImage = godo.DropletCreateImage{ID: imageId}
|
||||
}
|
||||
|
||||
droplet, _, err := client.Droplets.Create(context.TODO(), &godo.DropletCreateRequest{
|
||||
Name: c.DropletName,
|
||||
Region: c.Region,
|
||||
Size: c.Size,
|
||||
Image: godo.DropletCreateImage{
|
||||
Slug: c.Image,
|
||||
},
|
||||
Image: createImage,
|
||||
SSHKeys: []godo.DropletCreateSSHKey{
|
||||
{ID: sshKeyId},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user