move SSHInterface/SSHIPVersion fields to communitator.Config struct
This commit is contained in:
parent
cd851f8ac2
commit
b0c09087a2
|
@ -57,8 +57,7 @@ type RunConfig struct {
|
||||||
WindowsPasswordTimeout time.Duration `mapstructure:"windows_password_timeout"`
|
WindowsPasswordTimeout time.Duration `mapstructure:"windows_password_timeout"`
|
||||||
|
|
||||||
// Communicator settings
|
// Communicator settings
|
||||||
Comm communicator.Config `mapstructure:",squash"`
|
Comm communicator.Config `mapstructure:",squash"`
|
||||||
SSHInterface string `mapstructure:"ssh_interface"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
|
@ -84,12 +83,12 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
errs := c.Comm.Prepare(ctx)
|
errs := c.Comm.Prepare(ctx)
|
||||||
|
|
||||||
// Validating ssh_interface
|
// Validating ssh_interface
|
||||||
if c.SSHInterface != "public_ip" &&
|
if c.Comm.SSHInterface != "public_ip" &&
|
||||||
c.SSHInterface != "private_ip" &&
|
c.Comm.SSHInterface != "private_ip" &&
|
||||||
c.SSHInterface != "public_dns" &&
|
c.Comm.SSHInterface != "public_dns" &&
|
||||||
c.SSHInterface != "private_dns" &&
|
c.Comm.SSHInterface != "private_dns" &&
|
||||||
c.SSHInterface != "" {
|
c.Comm.SSHInterface != "" {
|
||||||
errs = append(errs, fmt.Errorf("Unknown interface type: %s", c.SSHInterface))
|
errs = append(errs, fmt.Errorf("Unknown interface type: %s", c.Comm.SSHInterface))
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Comm.SSHKeyPairName != "" {
|
if c.Comm.SSHKeyPairName != "" {
|
||||||
|
|
|
@ -203,7 +203,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
Config: &b.config.RunConfig.Comm,
|
Config: &b.config.RunConfig.Comm,
|
||||||
Host: awscommon.SSHHost(
|
Host: awscommon.SSHHost(
|
||||||
ec2conn,
|
ec2conn,
|
||||||
b.config.SSHInterface),
|
b.config.Comm.SSHInterface),
|
||||||
SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(),
|
SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(),
|
||||||
},
|
},
|
||||||
&common.StepProvision{},
|
&common.StepProvision{},
|
||||||
|
|
|
@ -220,7 +220,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
Config: &b.config.RunConfig.Comm,
|
Config: &b.config.RunConfig.Comm,
|
||||||
Host: awscommon.SSHHost(
|
Host: awscommon.SSHHost(
|
||||||
ec2conn,
|
ec2conn,
|
||||||
b.config.SSHInterface),
|
b.config.Comm.SSHInterface),
|
||||||
SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(),
|
SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(),
|
||||||
},
|
},
|
||||||
&common.StepProvision{},
|
&common.StepProvision{},
|
||||||
|
|
|
@ -196,7 +196,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
Config: &b.config.RunConfig.Comm,
|
Config: &b.config.RunConfig.Comm,
|
||||||
Host: awscommon.SSHHost(
|
Host: awscommon.SSHHost(
|
||||||
ec2conn,
|
ec2conn,
|
||||||
b.config.SSHInterface),
|
b.config.Comm.SSHInterface),
|
||||||
SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(),
|
SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(),
|
||||||
},
|
},
|
||||||
&common.StepProvision{},
|
&common.StepProvision{},
|
||||||
|
|
|
@ -278,7 +278,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
Config: &b.config.RunConfig.Comm,
|
Config: &b.config.RunConfig.Comm,
|
||||||
Host: awscommon.SSHHost(
|
Host: awscommon.SSHHost(
|
||||||
ec2conn,
|
ec2conn,
|
||||||
b.config.SSHInterface),
|
b.config.Comm.SSHInterface),
|
||||||
SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(),
|
SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(),
|
||||||
},
|
},
|
||||||
&common.StepProvision{},
|
&common.StepProvision{},
|
||||||
|
|
|
@ -127,8 +127,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
Config: &b.config.RunConfig.Comm,
|
Config: &b.config.RunConfig.Comm,
|
||||||
Host: CommHost(
|
Host: CommHost(
|
||||||
computeClient,
|
computeClient,
|
||||||
b.config.SSHInterface,
|
b.config.Comm.SSHInterface,
|
||||||
b.config.SSHIPVersion),
|
b.config.Comm.SSHIPVersion),
|
||||||
SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(),
|
SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(),
|
||||||
},
|
},
|
||||||
&common.StepProvision{},
|
&common.StepProvision{},
|
||||||
|
|
|
@ -13,9 +13,7 @@ import (
|
||||||
// RunConfig contains configuration for running an instance from a source
|
// RunConfig contains configuration for running an instance from a source
|
||||||
// image and details on how to access that launched image.
|
// image and details on how to access that launched image.
|
||||||
type RunConfig struct {
|
type RunConfig struct {
|
||||||
Comm communicator.Config `mapstructure:",squash"`
|
Comm communicator.Config `mapstructure:",squash"`
|
||||||
SSHInterface string `mapstructure:"ssh_interface"`
|
|
||||||
SSHIPVersion string `mapstructure:"ssh_ip_version"`
|
|
||||||
|
|
||||||
SourceImage string `mapstructure:"source_image"`
|
SourceImage string `mapstructure:"source_image"`
|
||||||
SourceImageName string `mapstructure:"source_image_name"`
|
SourceImageName string `mapstructure:"source_image_name"`
|
||||||
|
@ -131,7 +129,7 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
errs = append(errs, errors.New("A flavor must be specified"))
|
errs = append(errs, errors.New("A flavor must be specified"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.SSHIPVersion != "" && c.SSHIPVersion != "4" && c.SSHIPVersion != "6" {
|
if c.Comm.SSHIPVersion != "" && c.Comm.SSHIPVersion != "4" && c.Comm.SSHIPVersion != "6" {
|
||||||
errs = append(errs, errors.New("SSH IP version must be either 4 or 6"))
|
errs = append(errs, errors.New("SSH IP version must be either 4 or 6"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ type Config struct {
|
||||||
SSHKeyPairName string `mapstructure:"ssh_keypair_name"`
|
SSHKeyPairName string `mapstructure:"ssh_keypair_name"`
|
||||||
SSHTemporaryKeyPairName string `mapstructure:"temporary_key_pair_name"`
|
SSHTemporaryKeyPairName string `mapstructure:"temporary_key_pair_name"`
|
||||||
SSHPrivateKeyFile string `mapstructure:"ssh_private_key_file"`
|
SSHPrivateKeyFile string `mapstructure:"ssh_private_key_file"`
|
||||||
|
SSHInterface string `mapstructure:"ssh_interface"`
|
||||||
|
SSHIPVersion string `mapstructure:"ssh_ip_version"`
|
||||||
SSHPty bool `mapstructure:"ssh_pty"`
|
SSHPty bool `mapstructure:"ssh_pty"`
|
||||||
SSHTimeout time.Duration `mapstructure:"ssh_timeout"`
|
SSHTimeout time.Duration `mapstructure:"ssh_timeout"`
|
||||||
SSHAgentAuth bool `mapstructure:"ssh_agent_auth"`
|
SSHAgentAuth bool `mapstructure:"ssh_agent_auth"`
|
||||||
|
|
Loading…
Reference in New Issue