Commit 7439baf7 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge pull request #1343 from fnoeding/templating

Added support to use templates for more fields in null-builder and amazon-builder
parents bc208a5b de29431a
......@@ -98,6 +98,8 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
"temporary_key_pair_name": &c.TemporaryKeyPairName,
"vpc_id": &c.VpcId,
"availability_zone": &c.AvailabilityZone,
"user_data": &c.UserData,
"user_data_file": &c.UserDataFile,
}
for n, ptr := range templates {
......
......@@ -32,14 +32,28 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
c.tpl.UserVars = c.PackerUserVars
// Defaults
if c.Port == 0 {
c.Port = 22
}
// (none so far)
errs := common.CheckUnusedConfig(md)
templates := map[string]*string{
"host": &c.Host,
"ssh_username": &c.SSHUsername,
"ssh_password": &c.SSHPassword,
"ssh_private_key_file": &c.SSHPrivateKeyFile,
}
for n, ptr := range templates {
var err error
*ptr, err = c.tpl.Process(*ptr, nil)
if err != nil {
errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Error processing %s: %s", n, err))
}
}
if c.Host == "" {
errs = packer.MultiErrorAppend(errs,
fmt.Errorf("host must be specified"))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment