mirror of
https://github.com/hashicorp/packer.git
synced 2026-04-22 14:47:19 -04:00
builder/digitalocean: Use correct type for image for Droplet creates.
This commit is contained in:
parent
e8783873d0
commit
80b4e0425e
1 changed files with 9 additions and 3 deletions
|
|
@ -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},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue