diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d5abef5c..6f00a7e55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ IMPROVEMENTS: * builder/digitalocean: API requests will use HTTP proxy if specified by environmental variables. +BUG FIXES: + +* post-processor/vagrant: `output_path` templates now work again. + ## 0.3.2 (August 18, 2013) FEATURES: diff --git a/post-processor/vagrant/aws.go b/post-processor/vagrant/aws.go index 9454bc93c..92a55a5ff 100644 --- a/post-processor/vagrant/aws.go +++ b/post-processor/vagrant/aws.go @@ -43,20 +43,8 @@ func (p *AWSBoxPostProcessor) Configure(raws ...interface{}) error { // Accumulate any errors errs := common.CheckUnusedConfig(md) - templates := map[string]*string{ - "output": &p.config.OutputPath, - } - - 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)) - } - } - validates := map[string]*string{ + "output": &p.config.OutputPath, "vagrantfile_template": &p.config.VagrantfileTemplate, } @@ -90,8 +78,11 @@ func (p *AWSBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact } // Compile the output path - outputPath, err := ProcessOutputPath(p.config.OutputPath, - p.config.PackerBuildName, "aws", artifact) + outputPath, err := p.config.tpl.Process(p.config.OutputPath, &OutputPathTemplate{ + ArtifactId: artifact.Id(), + BuildName: p.config.PackerBuildName, + Provider: "aws", + }) if err != nil { return nil, false, err } diff --git a/post-processor/vagrant/util.go b/post-processor/vagrant/util.go index b194c129b..72cf83a5e 100644 --- a/post-processor/vagrant/util.go +++ b/post-processor/vagrant/util.go @@ -2,15 +2,12 @@ package vagrant import ( "archive/tar" - "bytes" "compress/gzip" "encoding/json" - "github.com/mitchellh/packer/packer" "io" "log" "os" "path/filepath" - "text/template" ) // OutputPathTemplate is the structure that is availalable within the @@ -108,26 +105,6 @@ func DirToBox(dst, dir string) error { return filepath.Walk(dir, tarWalk) } -// ProcessOutputPath takes an output path template and executes it, -// replacing variables with their respective values. -func ProcessOutputPath(path string, buildName string, provider string, artifact packer.Artifact) (string, error) { - var buf bytes.Buffer - - tplData := &OutputPathTemplate{ - ArtifactId: artifact.Id(), - BuildName: buildName, - Provider: provider, - } - - t, err := template.New("output").Parse(path) - if err != nil { - return "", err - } - - err = t.Execute(&buf, tplData) - return buf.String(), err -} - // WriteMetadata writes the "metadata.json" file for a Vagrant box. func WriteMetadata(dir string, contents interface{}) error { f, err := os.Create(filepath.Join(dir, "metadata.json")) diff --git a/post-processor/vagrant/virtualbox.go b/post-processor/vagrant/virtualbox.go index 858449468..521de7173 100644 --- a/post-processor/vagrant/virtualbox.go +++ b/post-processor/vagrant/virtualbox.go @@ -45,20 +45,8 @@ func (p *VBoxBoxPostProcessor) Configure(raws ...interface{}) error { // Accumulate any errors errs := common.CheckUnusedConfig(md) - templates := map[string]*string{ - "output": &p.config.OutputPath, - } - - 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)) - } - } - validates := map[string]*string{ + "output": &p.config.OutputPath, "vagrantfile_template": &p.config.VagrantfileTemplate, } @@ -85,8 +73,11 @@ func (p *VBoxBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifac } // Compile the output path - outputPath, err := ProcessOutputPath(p.config.OutputPath, - p.config.PackerBuildName, "virtualbox", artifact) + outputPath, err := p.config.tpl.Process(p.config.OutputPath, &OutputPathTemplate{ + ArtifactId: artifact.Id(), + BuildName: p.config.PackerBuildName, + Provider: "virtualbox", + }) if err != nil { return nil, false, err } diff --git a/post-processor/vagrant/vmware.go b/post-processor/vagrant/vmware.go index a57f2ebc9..3a18624e5 100644 --- a/post-processor/vagrant/vmware.go +++ b/post-processor/vagrant/vmware.go @@ -37,20 +37,8 @@ func (p *VMwareBoxPostProcessor) Configure(raws ...interface{}) error { // Accumulate any errors errs := common.CheckUnusedConfig(md) - templates := map[string]*string{ - "output": &p.config.OutputPath, - } - - 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)) - } - } - validates := map[string]*string{ + "output": &p.config.OutputPath, "vagrantfile_template": &p.config.VagrantfileTemplate, } @@ -70,8 +58,11 @@ func (p *VMwareBoxPostProcessor) Configure(raws ...interface{}) error { func (p *VMwareBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) { // Compile the output path - outputPath, err := ProcessOutputPath(p.config.OutputPath, - p.config.PackerBuildName, "vmware", artifact) + outputPath, err := p.config.tpl.Process(p.config.OutputPath, &OutputPathTemplate{ + ArtifactId: artifact.Id(), + BuildName: p.config.PackerBuildName, + Provider: "vmware", + }) if err != nil { return nil, false, err }