post-processor/vagrant: Only tar files
This commit is contained in:
parent
0d0c403037
commit
bd9c54e820
|
@ -31,7 +31,7 @@ const defaultConfig = `
|
||||||
},
|
},
|
||||||
|
|
||||||
"post-processors": {
|
"post-processors": {
|
||||||
"compress": "packer-post-processor-compress"
|
"vagrant": "packer-post-processor-vagrant"
|
||||||
},
|
},
|
||||||
|
|
||||||
"provisioners": {
|
"provisioners": {
|
||||||
|
|
|
@ -40,28 +40,31 @@ func (p *PostProcessor) Configure(raw interface{}) error {
|
||||||
return fmt.Errorf("output invalid template: %s", err)
|
return fmt.Errorf("output invalid template: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
mapConfig, ok := raw.(map[string]interface{})
|
/*
|
||||||
if !ok {
|
TODO(mitchellh): We need a way to get the keys...
|
||||||
panic("Raw configuration not a map")
|
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := pp.Configure(raw); err != nil {
|
errors := make([]error, 0)
|
||||||
errors = append(errors, err)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/mitchellh/packer/packer"
|
"github.com/mitchellh/packer/packer"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
@ -23,6 +24,7 @@ type OutputPathTemplate struct {
|
||||||
// box. This function does not perform checks to verify that dir is
|
// box. This function does not perform checks to verify that dir is
|
||||||
// actually a proper box. This is an expected precondition.
|
// actually a proper box. This is an expected precondition.
|
||||||
func DirToBox(dst, dir string) error {
|
func DirToBox(dst, dir string) error {
|
||||||
|
log.Printf("Turning dir into box: %s", dir)
|
||||||
dstF, err := os.Create(dst)
|
dstF, err := os.Create(dst)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
// This is the walk func that tars each of the files in the dir
|
||||||
tarWalk := func(path string, info os.FileInfo, prevErr error) error {
|
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)
|
f, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue