Valadating early

This commit is contained in:
John Davies-Colley 2017-11-28 11:46:01 +13:00
parent d4f37ab5f6
commit 0c787ec9df
2 changed files with 14 additions and 1 deletions

View File

@ -76,11 +76,24 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
c.RunTags = make(map[string]string)
}
if c.SSHPrivateIp && c.SSHInterface {
errs = append(errs, errors.New("ssh_interface and ssh_private_ip should not both be specified"))
}
// Legacy configurable
if c.SSHPrivateIp {
c.SSHInterface = "private_ip"
}
// Valadating ssh_interface
if c.SSHInterface != "public_ip" ||
c.SSHInterface != "private_ip" ||
c.SSHInterface != "public_dns" ||
c.SSHInterface != "private_dns" ||
c.SSHInterface != "" {
errs = append(errs, errors.New("Unknown interface type: %s", SSHInterface))
}
// Validation
errs := c.Comm.Prepare(ctx)
if c.SSHKeyPairName != "" {

View File

@ -51,7 +51,7 @@ func SSHHost(e ec2Describer, sshInterface string) func(multistep.StateBag) (stri
host = *i.PrivateDnsName
}
default:
return "", fmt.Errorf("unknown interface type: %s", sshInterface)
panic(fmt.Sprintf("Unknown interface type: %s", sshInterface))
}
} else if i.VpcId != nil && *i.VpcId != "" {
if i.PublicIpAddress != nil && *i.PublicIpAddress != "" {