From bd9c54e8201f9003022d69aa1ba83add2222825b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 27 Jun 2013 14:06:14 -0700 Subject: [PATCH] post-processor/vagrant: Only tar files --- config.go | 2 +- post-processor/vagrant/post-processor.go | 39 +++++++++++++----------- post-processor/vagrant/util.go | 9 ++++++ 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/config.go b/config.go index 3e3278371..f2ed48956 100644 --- a/config.go +++ b/config.go @@ -31,7 +31,7 @@ const defaultConfig = ` }, "post-processors": { - "compress": "packer-post-processor-compress" + "vagrant": "packer-post-processor-vagrant" }, "provisioners": { diff --git a/post-processor/vagrant/post-processor.go b/post-processor/vagrant/post-processor.go index a806460f2..dccf403e9 100644 --- a/post-processor/vagrant/post-processor.go +++ b/post-processor/vagrant/post-processor.go @@ -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 } diff --git a/post-processor/vagrant/util.go b/post-processor/vagrant/util.go index 5cc52bfb3..515f7f3d8 100644 --- a/post-processor/vagrant/util.go +++ b/post-processor/vagrant/util.go @@ -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