Skip to content

Commit

Permalink
provider/digitalocean: fix issue hashicorp#3628 by accepting SSH fing…
Browse files Browse the repository at this point in the history
…erprints
  • Loading branch information
aybabtme committed Oct 25, 2015
1 parent 965399c commit 7594c09
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions builtin/providers/digitalocean/resource_digitalocean_droplet.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,17 @@ func resourceDigitalOceanDropletCreate(d *schema.ResourceData, meta interface{})
opts.SSHKeys = make([]godo.DropletCreateSSHKey, 0, sshKeys)
for i := 0; i < sshKeys; i++ {
key := fmt.Sprintf("ssh_keys.%d", i)
id, err := strconv.Atoi(d.Get(key).(string))
if err != nil {
return err
sshKeyRef := d.Get(key).(string)

var sshKey godo.DropletCreateSSHKey
// sshKeyRef can be either an ID or a fingerprint
if id, err := strconv.Atoi(sshKeyRef); err == nil {
sshKey.ID = id
} else {
sshKey.Fingerprint = sshKeyRef
}

opts.SSHKeys = append(opts.SSHKeys, godo.DropletCreateSSHKey{
ID: id,
})
opts.SSHKeys = append(opts.SSHKeys, sshKey)
}
}

Expand Down

0 comments on commit 7594c09

Please sign in to comment.