Commit bf67c6c3 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

provisioner/file: use the template processing stuff

parent c0235886
......@@ -14,6 +14,8 @@ type config struct {
// The remote path where the local file will be uploaded to.
Destination string
tpl *common.Template
}
type Provisioner struct {
......@@ -26,9 +28,28 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
return err
}
p.config.tpl, err = common.NewTemplate()
if err != nil {
return err
}
// Accumulate any errors
errs := common.CheckUnusedConfig(md)
templates := map[string]*string{
"source": &p.config.Source,
"destination": &p.config.Destination,
}
for n, ptr := range templates {
var err error
*ptr, err = p.config.tpl.Process(*ptr, nil)
if err != nil {
errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Error processing %s: %s", n, err))
}
}
if _, err := os.Stat(p.config.Source); err != nil {
errs = packer.MultiErrorAppend(errs,
fmt.Errorf("Bad source '%s': %s", p.config.Source, err))
......
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