From 9a9b82715b989ded3e7590acf4f948f0d5942f34 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Tue, 28 Aug 2018 16:10:39 +0200 Subject: [PATCH] config.Comm.SSHKeyPair => SSHKeyPairName --- builder/alicloud/ecs/step_attach_keypair.go | 4 ++-- builder/alicloud/ecs/step_config_key_pair.go | 4 ++-- builder/amazon/common/run_config.go | 4 ++-- builder/amazon/common/step_key_pair.go | 10 +++++----- builder/openstack/step_key_pair.go | 8 ++++---- builder/openstack/step_run_source_server.go | 2 +- helper/communicator/config.go | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/builder/alicloud/ecs/step_attach_keypair.go b/builder/alicloud/ecs/step_attach_keypair.go index 828606555..9f5b63676 100644 --- a/builder/alicloud/ecs/step_attach_keypair.go +++ b/builder/alicloud/ecs/step_attach_keypair.go @@ -21,7 +21,7 @@ func (s *stepAttachKeyPair) Run(_ context.Context, state multistep.StateBag) mul config := state.Get("config").(Config) instance := state.Get("instance").(*ecs.InstanceAttributesType) timeoutPoint := time.Now().Add(120 * time.Second) - keyPairName := config.Comm.SSHKeyPair + keyPairName := config.Comm.SSHKeyPairName if keyPairName == "" { return multistep.ActionContinue } @@ -55,7 +55,7 @@ func (s *stepAttachKeyPair) Cleanup(state multistep.StateBag) { config := state.Get("config").(Config) ui := state.Get("ui").(packer.Ui) instance := state.Get("instance").(*ecs.InstanceAttributesType) - keyPairName := config.Comm.SSHKeyPair + keyPairName := config.Comm.SSHKeyPairName if keyPairName == "" { return } diff --git a/builder/alicloud/ecs/step_config_key_pair.go b/builder/alicloud/ecs/step_config_key_pair.go index 3efb2401f..a66e086e0 100644 --- a/builder/alicloud/ecs/step_config_key_pair.go +++ b/builder/alicloud/ecs/step_config_key_pair.go @@ -38,7 +38,7 @@ func (s *stepConfigAlicloudKeyPair) Run(_ context.Context, state multistep.State return multistep.ActionHalt } - config.Comm.SSHKeyPair = s.KeyPairName + config.Comm.SSHKeyPairName = s.KeyPairName config.Comm.SSHPrivateKey = privateKeyBytes return multistep.ActionContinue @@ -77,7 +77,7 @@ func (s *stepConfigAlicloudKeyPair) Run(_ context.Context, state multistep.State s.keyName = s.TemporaryKeyPairName // Set some state data for use in future steps - config.Comm.SSHKeyPair = s.keyName + config.Comm.SSHKeyPairName = s.keyName config.Comm.SSHPrivateKey = []byte(keyResp.PrivateKeyBody) // If we're in debug mode, output the private key to the working diff --git a/builder/amazon/common/run_config.go b/builder/amazon/common/run_config.go index f32eb3ed3..aca5e0143 100644 --- a/builder/amazon/common/run_config.go +++ b/builder/amazon/common/run_config.go @@ -66,7 +66,7 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error { // ssh_private_key_file, then create a temporary one, but only if the // temporary_key_pair_name has not been provided and we are not using // ssh_password. - if c.Comm.SSHKeyPair == "" && c.TemporaryKeyPairName == "" && + if c.Comm.SSHKeyPairName == "" && c.TemporaryKeyPairName == "" && c.Comm.SSHPrivateKeyFile == "" && c.Comm.SSHPassword == "" { c.TemporaryKeyPairName = fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID()) @@ -92,7 +92,7 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error { errs = append(errs, fmt.Errorf("Unknown interface type: %s", c.SSHInterface)) } - if c.Comm.SSHKeyPair != "" { + if c.Comm.SSHKeyPairName != "" { if c.Comm.Type == "winrm" && c.Comm.WinRMPassword == "" && c.Comm.SSHPrivateKeyFile == "" { errs = append(errs, fmt.Errorf("ssh_private_key_file must be provided to retrieve the winrm password when using ssh_keypair_name.")) } else if c.Comm.SSHPrivateKeyFile == "" && !c.Comm.SSHAgentAuth { diff --git a/builder/amazon/common/step_key_pair.go b/builder/amazon/common/step_key_pair.go index 6bb8db532..71c286dad 100644 --- a/builder/amazon/common/step_key_pair.go +++ b/builder/amazon/common/step_key_pair.go @@ -39,14 +39,14 @@ func (s *StepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep return multistep.ActionContinue } - if s.Comm.SSHAgentAuth && s.Comm.SSHKeyPair == "" { + if s.Comm.SSHAgentAuth && s.Comm.SSHKeyPairName == "" { ui.Say("Using SSH Agent with key pair in Source AMI") return multistep.ActionContinue } - if s.Comm.SSHAgentAuth && s.Comm.SSHKeyPair != "" { - ui.Say(fmt.Sprintf("Using SSH Agent for existing key pair %s", s.Comm.SSHKeyPair)) - state.Put("keyPair", s.Comm.SSHKeyPair) + if s.Comm.SSHAgentAuth && s.Comm.SSHKeyPairName != "" { + ui.Say(fmt.Sprintf("Using SSH Agent for existing key pair %s", s.Comm.SSHKeyPairName)) + state.Put("keyPair", s.Comm.SSHKeyPairName) return multistep.ActionContinue } @@ -69,7 +69,7 @@ func (s *StepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep s.doCleanup = true // Set some data for use in future steps - s.Comm.SSHKeyPair = s.TemporaryKeyPairName + s.Comm.SSHKeyPairName = s.TemporaryKeyPairName s.Comm.SSHPrivateKey = []byte(*keyResp.KeyMaterial) // If we're in debug mode, output the private key to the working diff --git a/builder/openstack/step_key_pair.go b/builder/openstack/step_key_pair.go index fb8ca958d..5db057f06 100644 --- a/builder/openstack/step_key_pair.go +++ b/builder/openstack/step_key_pair.go @@ -39,7 +39,7 @@ func (s *StepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep } config.Comm.SSHPrivateKey = privateKeyBytes - config.Comm.SSHKeyPair = s.KeyPairName + config.Comm.SSHKeyPairName = s.KeyPairName return multistep.ActionContinue } @@ -51,13 +51,13 @@ func (s *StepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep if s.SSHAgentAuth && s.KeyPairName != "" { ui.Say(fmt.Sprintf("Using SSH Agent for existing key pair %s", s.KeyPairName)) - config.Comm.SSHKeyPair = "" + config.Comm.SSHKeyPairName = "" return multistep.ActionContinue } if s.TemporaryKeyPairName == "" { ui.Say("Not using temporary keypair") - config.Comm.SSHKeyPair = "" + config.Comm.SSHKeyPairName = "" return multistep.ActionContinue } @@ -117,7 +117,7 @@ func (s *StepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep s.doCleanup = true // Set some state data for use in future steps - config.Comm.SSHKeyPair = s.TemporaryKeyPairName + config.Comm.SSHKeyPairName = s.TemporaryKeyPairName config.Comm.SSHPrivateKey = []byte(keypair.PrivateKey) return multistep.ActionContinue diff --git a/builder/openstack/step_run_source_server.go b/builder/openstack/step_run_source_server.go index 6f2b78c41..3b0a4c5c7 100644 --- a/builder/openstack/step_run_source_server.go +++ b/builder/openstack/step_run_source_server.go @@ -107,7 +107,7 @@ func (s *StepRunSourceServer) Run(_ context.Context, state multistep.StateBag) m } // Add keypair to the server create options. - keyName := config.Comm.SSHKeyPair + keyName := config.Comm.SSHKeyPairName if keyName != "" { serverOptsExt = keypairs.CreateOptsExt{ CreateOptsBuilder: serverOptsExt, diff --git a/helper/communicator/config.go b/helper/communicator/config.go index 35655165a..45f5daa05 100644 --- a/helper/communicator/config.go +++ b/helper/communicator/config.go @@ -29,7 +29,7 @@ type Config struct { SSHPassword string `mapstructure:"ssh_password"` SSHPublicKey []byte `mapstructure:"ssh_public_key"` SSHPrivateKey []byte `mapstructure:"ssh_private_key"` - SSHKeyPair string `mapstructure:"ssh_keypair_name"` + SSHKeyPairName string `mapstructure:"ssh_keypair_name"` SSHPrivateKeyFile string `mapstructure:"ssh_private_key_file"` SSHPty bool `mapstructure:"ssh_pty"` SSHTimeout time.Duration `mapstructure:"ssh_timeout"`