diff --git a/builder/parallels/common/ssh.go b/builder/parallels/common/ssh.go index 9e0b2b907..35b43311e 100644 --- a/builder/parallels/common/ssh.go +++ b/builder/parallels/common/ssh.go @@ -32,7 +32,7 @@ func SSHConfigFunc(config SSHConfig) func(multistep.StateBag) (*ssh.ClientConfig packerssh.PasswordKeyboardInteractive(config.Comm.SSHPassword)), } - if config.SSHKeyPath != "" { + if config.Comm.SSHPrivateKey != "" { signer, err := commonssh.FileSigner(config.Comm.SSHPrivateKey) if err != nil { return nil, err diff --git a/builder/parallels/common/ssh_config.go b/builder/parallels/common/ssh_config.go index bea164b06..e7d9357ff 100644 --- a/builder/parallels/common/ssh_config.go +++ b/builder/parallels/common/ssh_config.go @@ -12,15 +12,11 @@ type SSHConfig struct { // These are deprecated, but we keep them around for BC // TODO(@mitchellh): remove - SSHKeyPath string `mapstructure:"ssh_key_path"` SSHWaitTimeout time.Duration `mapstructure:"ssh_wait_timeout"` } func (c *SSHConfig) Prepare(ctx *interpolate.Context) []error { // TODO: backwards compatibility, write fixer instead - if c.SSHKeyPath != "" { - c.Comm.SSHPrivateKey = c.SSHKeyPath - } if c.SSHWaitTimeout != 0 { c.Comm.SSHTimeout = c.SSHWaitTimeout } diff --git a/builder/parallels/common/ssh_config_test.go b/builder/parallels/common/ssh_config_test.go index 01dd1ff62..887b59f8f 100644 --- a/builder/parallels/common/ssh_config_test.go +++ b/builder/parallels/common/ssh_config_test.go @@ -28,19 +28,19 @@ func TestSSHConfigPrepare(t *testing.T) { } } -func TestSSHConfigPrepare_SSHKeyPath(t *testing.T) { +func TestSSHConfigPrepare_SSHPrivateKey(t *testing.T) { var c *SSHConfig var errs []error c = testSSHConfig() - c.SSHKeyPath = "" + c.Comm.SSHPrivateKey = "" errs = c.Prepare(testConfigTemplate(t)) if len(errs) > 0 { t.Fatalf("should not have error: %#v", errs) } c = testSSHConfig() - c.SSHKeyPath = "/i/dont/exist" + c.Comm.SSHPrivateKey = "/i/dont/exist" errs = c.Prepare(testConfigTemplate(t)) if len(errs) == 0 { t.Fatal("should have error") @@ -59,7 +59,7 @@ func TestSSHConfigPrepare_SSHKeyPath(t *testing.T) { } c = testSSHConfig() - c.SSHKeyPath = tf.Name() + c.Comm.SSHPrivateKey = tf.Name() errs = c.Prepare(testConfigTemplate(t)) if len(errs) == 0 { t.Fatal("should have error") @@ -70,7 +70,7 @@ func TestSSHConfigPrepare_SSHKeyPath(t *testing.T) { tf.Truncate(0) tf.Write([]byte(testPem)) c = testSSHConfig() - c.SSHKeyPath = tf.Name() + c.Comm.SSHPrivateKey = tf.Name() errs = c.Prepare(testConfigTemplate(t)) if len(errs) > 0 { t.Fatalf("should not have error: %#v", errs) diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index 66c78e45e..59490049c 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -110,7 +110,6 @@ type Config struct { // These are deprecated, but we keep them around for BC // TODO(@mitchellh): remove - SSHKeyPath string `mapstructure:"ssh_key_path"` SSHWaitTimeout time.Duration `mapstructure:"ssh_wait_timeout"` // TODO(mitchellh): deprecate @@ -212,9 +211,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { } // TODO: backwards compatibility, write fixer instead - if b.config.SSHKeyPath != "" { - b.config.Comm.SSHPrivateKey = b.config.SSHKeyPath - } if b.config.SSHWaitTimeout != 0 { b.config.Comm.SSHTimeout = b.config.SSHWaitTimeout } diff --git a/builder/qemu/builder_test.go b/builder/qemu/builder_test.go index a7ce88e6d..cebcf6fbb 100644 --- a/builder/qemu/builder_test.go +++ b/builder/qemu/builder_test.go @@ -357,11 +357,11 @@ func TestBuilderPrepare_SSHHostPort(t *testing.T) { } } -func TestBuilderPrepare_sshKeyPath(t *testing.T) { +func TestBuilderPrepare_SSHPrivateKey(t *testing.T) { var b Builder config := testConfig() - config["ssh_key_path"] = "" + config["ssh_private_key_file"] = "" b = Builder{} warns, err := b.Prepare(config) if len(warns) > 0 { @@ -371,7 +371,7 @@ func TestBuilderPrepare_sshKeyPath(t *testing.T) { t.Fatalf("should not have error: %s", err) } - config["ssh_key_path"] = "/i/dont/exist" + config["ssh_private_key_file"] = "/i/dont/exist" b = Builder{} warns, err = b.Prepare(config) if len(warns) > 0 { @@ -393,7 +393,7 @@ func TestBuilderPrepare_sshKeyPath(t *testing.T) { t.Fatalf("err: %s", err) } - config["ssh_key_path"] = tf.Name() + config["ssh_private_key_file"] = tf.Name() b = Builder{} warns, err = b.Prepare(config) if len(warns) > 0 { @@ -407,7 +407,7 @@ func TestBuilderPrepare_sshKeyPath(t *testing.T) { tf.Seek(0, 0) tf.Truncate(0) tf.Write([]byte(testPem)) - config["ssh_key_path"] = tf.Name() + config["ssh_private_key_file"] = tf.Name() b = Builder{} warns, err = b.Prepare(config) if len(warns) > 0 { diff --git a/builder/virtualbox/common/ssh.go b/builder/virtualbox/common/ssh.go index b04a14ac8..c9080df1d 100644 --- a/builder/virtualbox/common/ssh.go +++ b/builder/virtualbox/common/ssh.go @@ -24,7 +24,7 @@ func SSHConfigFunc(config SSHConfig) func(multistep.StateBag) (*gossh.ClientConf ssh.PasswordKeyboardInteractive(config.Comm.SSHPassword)), } - if config.SSHKeyPath != "" { + if config.Comm.SSHPrivateKey != "" { signer, err := commonssh.FileSigner(config.Comm.SSHPrivateKey) if err != nil { return nil, err diff --git a/builder/virtualbox/common/ssh_config.go b/builder/virtualbox/common/ssh_config.go index 8997c58f7..5095f2b03 100644 --- a/builder/virtualbox/common/ssh_config.go +++ b/builder/virtualbox/common/ssh_config.go @@ -17,7 +17,6 @@ type SSHConfig struct { // These are deprecated, but we keep them around for BC // TODO(@mitchellh): remove - SSHKeyPath string `mapstructure:"ssh_key_path"` SSHWaitTimeout time.Duration `mapstructure:"ssh_wait_timeout"` } @@ -31,9 +30,6 @@ func (c *SSHConfig) Prepare(ctx *interpolate.Context) []error { } // TODO: backwards compatibility, write fixer instead - if c.SSHKeyPath != "" { - c.Comm.SSHPrivateKey = c.SSHKeyPath - } if c.SSHWaitTimeout != 0 { c.Comm.SSHTimeout = c.SSHWaitTimeout } diff --git a/builder/virtualbox/common/ssh_config_test.go b/builder/virtualbox/common/ssh_config_test.go index e5b918fe9..72d92ac11 100644 --- a/builder/virtualbox/common/ssh_config_test.go +++ b/builder/virtualbox/common/ssh_config_test.go @@ -59,19 +59,19 @@ func TestSSHConfigPrepare_SSHHostPort(t *testing.T) { } } -func TestSSHConfigPrepare_SSHKeyPath(t *testing.T) { +func TestSSHConfigPrepare_SSHPrivateKey(t *testing.T) { var c *SSHConfig var errs []error c = testSSHConfig() - c.SSHKeyPath = "" + c.Comm.SSHPrivateKey = "" errs = c.Prepare(testConfigTemplate(t)) if len(errs) > 0 { t.Fatalf("should not have error: %#v", errs) } c = testSSHConfig() - c.SSHKeyPath = "/i/dont/exist" + c.Comm.SSHPrivateKey = "/i/dont/exist" errs = c.Prepare(testConfigTemplate(t)) if len(errs) == 0 { t.Fatal("should have error") @@ -90,7 +90,7 @@ func TestSSHConfigPrepare_SSHKeyPath(t *testing.T) { } c = testSSHConfig() - c.SSHKeyPath = tf.Name() + c.Comm.SSHPrivateKey = tf.Name() errs = c.Prepare(testConfigTemplate(t)) if len(errs) == 0 { t.Fatal("should have error") @@ -101,7 +101,7 @@ func TestSSHConfigPrepare_SSHKeyPath(t *testing.T) { tf.Truncate(0) tf.Write([]byte(testPem)) c = testSSHConfig() - c.SSHKeyPath = tf.Name() + c.Comm.SSHPrivateKey = tf.Name() errs = c.Prepare(testConfigTemplate(t)) if len(errs) > 0 { t.Fatalf("should not have error: %#v", errs) diff --git a/builder/vmware/common/ssh_config.go b/builder/vmware/common/ssh_config.go index 86754f6e4..a0bbf942e 100644 --- a/builder/vmware/common/ssh_config.go +++ b/builder/vmware/common/ssh_config.go @@ -12,16 +12,12 @@ type SSHConfig struct { // These are deprecated, but we keep them around for BC // TODO(@mitchellh): remove - SSHKeyPath string `mapstructure:"ssh_key_path"` SSHSkipRequestPty bool `mapstructure:"ssh_skip_request_pty"` SSHWaitTimeout time.Duration `mapstructure:"ssh_wait_timeout"` } func (c *SSHConfig) Prepare(ctx *interpolate.Context) []error { // TODO: backwards compatibility, write fixer instead - if c.SSHKeyPath != "" { - c.Comm.SSHPrivateKey = c.SSHKeyPath - } if c.SSHWaitTimeout != 0 { c.Comm.SSHTimeout = c.SSHWaitTimeout } diff --git a/builder/vmware/common/ssh_config_test.go b/builder/vmware/common/ssh_config_test.go index 1fd84c02f..64889195f 100644 --- a/builder/vmware/common/ssh_config_test.go +++ b/builder/vmware/common/ssh_config_test.go @@ -28,19 +28,19 @@ func TestSSHConfigPrepare(t *testing.T) { } } -func TestSSHConfigPrepare_SSHKeyPath(t *testing.T) { +func TestSSHConfigPrepare_SSHPrivateKey(t *testing.T) { var c *SSHConfig var errs []error c = testSSHConfig() - c.SSHKeyPath = "" + c.Comm.SSHPrivateKey = "" errs = c.Prepare(testConfigTemplate(t)) if len(errs) > 0 { t.Fatalf("should not have error: %#v", errs) } c = testSSHConfig() - c.SSHKeyPath = "/i/dont/exist" + c.Comm.SSHPrivateKey = "/i/dont/exist" errs = c.Prepare(testConfigTemplate(t)) if len(errs) == 0 { t.Fatal("should have error") @@ -59,7 +59,7 @@ func TestSSHConfigPrepare_SSHKeyPath(t *testing.T) { } c = testSSHConfig() - c.SSHKeyPath = tf.Name() + c.Comm.SSHPrivateKey = tf.Name() errs = c.Prepare(testConfigTemplate(t)) if len(errs) == 0 { t.Fatal("should have error") @@ -70,7 +70,7 @@ func TestSSHConfigPrepare_SSHKeyPath(t *testing.T) { tf.Truncate(0) tf.Write([]byte(testPem)) c = testSSHConfig() - c.SSHKeyPath = tf.Name() + c.Comm.SSHPrivateKey = tf.Name() errs = c.Prepare(testConfigTemplate(t)) if len(errs) > 0 { t.Fatalf("should not have error: %#v", errs)