fix communicator

This commit is contained in:
Megan Marsh 2018-01-18 15:52:31 -08:00 committed by Matthew Hooker
parent 6556a851dc
commit f208a071a4
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
2 changed files with 8 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import (
"github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
) )
@ -48,5 +49,10 @@ func NewConfig(raws ...interface{}) (*Config, error) {
return nil, fmt.Errorf("Error parsing API Endpoint: %s", err) return nil, fmt.Errorf("Error parsing API Endpoint: %s", err)
} }
var errs *packer.MultiError
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
}
return c, nil return c, nil
} }

View File

@ -20,7 +20,7 @@ func (s *stepCreateInstance) Run(state multistep.StateBag) multistep.StepAction
sshPublicKey := strings.TrimSpace(state.Get("publicKey").(string)) sshPublicKey := strings.TrimSpace(state.Get("publicKey").(string))
// Load the dynamically-generated SSH key into the Oracle Compute cloud. // Load the dynamically-generated SSH key into the Oracle Compute cloud.
sshKeyName := fmt.Sprintf("/Compute-%s/%s/packer_dynamic_key", config.IdentityDomain, config.Username) sshKeyName := fmt.Sprintf("/Compute-%s/%s/packer_generated_key", config.IdentityDomain, config.Username)
sshKeysClient := client.SSHKeys() sshKeysClient := client.SSHKeys()
sshKeysInput := compute.CreateSSHKeyInput{ sshKeysInput := compute.CreateSSHKeyInput{
@ -31,7 +31,7 @@ func (s *stepCreateInstance) Run(state multistep.StateBag) multistep.StepAction
keyInfo, err := sshKeysClient.CreateSSHKey(&sshKeysInput) keyInfo, err := sshKeysClient.CreateSSHKey(&sshKeysInput)
if err != nil { if err != nil {
// Key already exists; update key instead // Key already exists; update key instead
if strings.Contains(err.Error(), "packer_dynamic_key already exists") { if strings.Contains(err.Error(), "packer_generated_key already exists") {
updateKeysInput := compute.UpdateSSHKeyInput{ updateKeysInput := compute.UpdateSSHKeyInput{
Name: sshKeyName, Name: sshKeyName,
Key: sshPublicKey, Key: sshPublicKey,