From e251adb37e9ddbfaa92d7b27901d732cbbb6b399 Mon Sep 17 00:00:00 2001 From: Don Kuntz Date: Fri, 22 Feb 2019 10:18:37 -0600 Subject: [PATCH] Make the amazon-private-ip fixer errors more visible At present, when using the packer fix command on a template that has "ssh_private_ip" set to anything but a boolean value, the fixer will fail, and appear to fail silently, simply returning a non-zero status code without any message. To determine what happened, users have to know to set PACKER_LOG=1 to make the log message visible. So far as I can tell, this is the only instance of log.Fatalf being called, and based on the surrounding code the better solution would be to return an error, which will then be visible to users of packer fix without having to look in the logs. --- fix/fixer_amazon_private_ip.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fix/fixer_amazon_private_ip.go b/fix/fixer_amazon_private_ip.go index 7b0189ca5..bf1575644 100644 --- a/fix/fixer_amazon_private_ip.go +++ b/fix/fixer_amazon_private_ip.go @@ -1,7 +1,7 @@ package fix import ( - "log" + "fmt" "strconv" "strings" @@ -53,7 +53,7 @@ func (FixerAmazonPrivateIP) Fix(input map[string]interface{}) (map[string]interf var err error privateIP, err = strconv.ParseBool(privateIPi.(string)) if err != nil { - log.Fatalf("Wrong type for ssh_private_ip") + return nil, fmt.Errorf("ssh_private_ip is not a boolean") continue } }