post-processor/vagrant: Only tar files

This commit is contained in:
Mitchell Hashimoto 2013-06-27 14:06:14 -07:00
parent e5a23492ea
commit c0d690209c
3 changed files with 31 additions and 19 deletions

View File

@ -31,7 +31,7 @@ const defaultConfig = `
},
"post-processors": {
"compress": "packer-post-processor-compress"
"vagrant": "packer-post-processor-vagrant"
},
"provisioners": {

View File

@ -40,28 +40,31 @@ func (p *PostProcessor) Configure(raw interface{}) error {
return fmt.Errorf("output invalid template: %s", err)
}
mapConfig, ok := raw.(map[string]interface{})
if !ok {
panic("Raw configuration not a map")
}
errors := make([]error, 0)
for k, raw := range mapConfig {
pp := keyToPostProcessor(k)
if pp == nil {
continue
/*
TODO(mitchellh): We need a way to get the keys...
mapConfig, ok := raw.(map[string]interface{})
if !ok {
panic("Raw configuration not a map")
}
if err := pp.Configure(raw); err != nil {
errors = append(errors, err)
errors := make([]error, 0)
for k, raw := range mapConfig {
pp := keyToPostProcessor(k)
if pp == nil {
continue
}
if err := pp.Configure(raw); err != nil {
errors = append(errors, err)
}
p.premade[k] = pp
}
p.premade[k] = pp
}
if len(errors) > 0 {
return &packer.MultiError{errors}
}
if len(errors) > 0 {
return &packer.MultiError{errors}
}
*/
return nil
}

View File

@ -7,6 +7,7 @@ import (
"encoding/json"
"github.com/mitchellh/packer/packer"
"io"
"log"
"os"
"path/filepath"
"text/template"
@ -23,6 +24,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)
dstF, err := os.Create(dst)
if err != nil {
return err
@ -37,6 +39,13 @@ func DirToBox(dst, dir string) error {
// This is the walk func that tars each of the files in the dir
tarWalk := func(path string, info os.FileInfo, prevErr error) error {
// Skip directories
if info.IsDir() {
log.Printf("Skiping directory '%s' for box '%s'", path, dst)
return nil
}
log.Printf("Box add: '%s' to '%s'", path, dst)
f, err := os.Open(path)
if err != nil {
return err