Skip to content

Commit

Permalink
Merge pull request #3633 from aybabtme/provider/digitalocean-fix-issu…
Browse files Browse the repository at this point in the history
…e-3628

provider/digitalocean: fix issue #3628 by accepting SSH fingerprints
  • Loading branch information
phinze committed Oct 29, 2015
2 parents 76c488d + 7594c09 commit 845e172
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 845e172

Please sign in to comment.