post-processor/vagrant: provider PPs get properly configured

This commit is contained in:
Mitchell Hashimoto 2013-07-05 11:11:54 -07:00
parent 8b25acfab6
commit 324a2229a6
4 changed files with 15 additions and 6 deletions

View File

@ -12,6 +12,8 @@ IMPROVEMENTS:
BUG FIXES:
* vagrant: The `BuildName` template propery works properly in
the output path.
* vagrant: Properly configure the provider-specific post-processors so
things like `vagrantfile_template` work. [GH-129]

View File

@ -105,6 +105,7 @@ func (p *AWSBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact
// Compress the directory to the given output path
if err := DirToBox(outputPath, dir); err != nil {
err = fmt.Errorf("error creating box: %s", err)
return nil, false, err
}

View File

@ -40,8 +40,10 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
}
ppExtraConfig := make(map[string]interface{})
if p.config.OutputPath == "" {
p.config.OutputPath = "packer_{{ .BuildName }}_{{.Provider}}.box"
ppExtraConfig["output"] = p.config.OutputPath
}
_, err := template.New("output").Parse(p.config.OutputPath)
@ -49,16 +51,15 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return fmt.Errorf("output invalid template: %s", err)
}
// Store the extra configuration for post-processors
p.rawConfigs = append(p.rawConfigs, ppExtraConfig)
// TODO(mitchellh): Properly handle multiple raw configs
var mapConfig map[string]interface{}
if err := mapstructure.Decode(raws[0], &mapConfig); err != nil {
return err
}
packerConfig := map[string]interface{}{
packer.BuildNameConfigKey: p.config.PackerBuildName,
}
p.premade = make(map[string]packer.PostProcessor)
errors := make([]error, 0)
for k, raw := range mapConfig {
@ -67,7 +68,12 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
continue
}
if err := pp.Configure(raw, packerConfig); err != nil {
// Create the proper list of configurations
ppConfigs := make([]interface{}, 0, len(p.rawConfigs)+1)
copy(ppConfigs, p.rawConfigs)
ppConfigs = append(ppConfigs, raw)
if err := pp.Configure(ppConfigs...); err != nil {
errors = append(errors, err)
}

View File

@ -25,7 +25,7 @@ type OutputPathTemplate struct {
// box. This function does not perform checks to verify that dir is
// actually a proper box. This is an expected precondition.
func DirToBox(dst, dir string) error {
log.Printf("Turning dir into box: %s", dir)
log.Printf("Turning dir into box: %s => %s", dir, dst)
dstF, err := os.Create(dst)
if err != nil {
return err