From 10aaa49bebf7edbb4c50005aa5b19d5d4f3d434d Mon Sep 17 00:00:00 2001 From: John Davies-Colley Date: Tue, 28 Nov 2017 14:26:55 +1300 Subject: [PATCH] =?UTF-8?q?fixing=20tests=20and=20funky=20logic=20?= =?UTF-8?q?=F0=9F=92=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- builder/amazon/common/run_config.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/builder/amazon/common/run_config.go b/builder/amazon/common/run_config.go index 7e523740a..4f20ed3b4 100644 --- a/builder/amazon/common/run_config.go +++ b/builder/amazon/common/run_config.go @@ -76,7 +76,9 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error { c.RunTags = make(map[string]string) } - if c.SSHPrivateIp && c.SSHInterface { + // Validation + errs := c.Comm.Prepare(ctx) + if c.SSHPrivateIp && c.SSHInterface != "" { errs = append(errs, errors.New("ssh_interface and ssh_private_ip should not both be specified")) } @@ -86,16 +88,14 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error { } // Valadating ssh_interface - if c.SSHInterface != "public_ip" || - c.SSHInterface != "private_ip" || - c.SSHInterface != "public_dns" || - c.SSHInterface != "private_dns" || + 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)) + errs = append(errs, errors.New(fmt.Sprintf("Unknown interface type: %s", c.SSHInterface))) } - // Validation - errs := c.Comm.Prepare(ctx) if c.SSHKeyPairName != "" { if c.Comm.Type == "winrm" && c.Comm.WinRMPassword == "" && c.Comm.SSHPrivateKey == "" { errs = append(errs, errors.New("A private_key_file must be provided to retrieve the winrm password when using ssh_keypair_name."))