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.
This commit is contained in:
Don Kuntz 2019-02-22 10:18:37 -06:00
parent 440f1f5f3c
commit e251adb37e
1 changed files with 2 additions and 2 deletions

View File

@ -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
}
}