builder/virtualbox: proper artifact [GH-23]

This commit is contained in:
Mitchell Hashimoto 2013-06-19 21:12:11 -07:00
parent b8103ff9c0
commit 64aed2b34a
2 changed files with 54 additions and 1 deletions

View File

@ -0,0 +1,33 @@
package virtualbox
import (
"fmt"
"os"
)
// Artifact is the result of running the VirtualBox builder, namely a set
// of files associated with the resulting machine.
type Artifact struct {
dir string
f []string
}
func (*Artifact) BuilderId() string {
return BuilderId
}
func (a *Artifact) Files() []string {
return a.f
}
func (*Artifact) Id() string {
return "VM"
}
func (a *Artifact) String() string {
return fmt.Sprintf("VM files in directory: %s", a.dir)
}
func (a *Artifact) Destroy() error {
return os.RemoveAll(a.dir)
}

View File

@ -11,6 +11,7 @@ import (
"net/url"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
)
@ -231,7 +232,26 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
return nil, rawErr.(error)
}
return nil, nil
// Compile the artifact list
files := make([]string, 0, 5)
visit := func(path string, info os.FileInfo, err error) error {
if !info.IsDir() {
files = append(files, path)
}
return err
}
if err := filepath.Walk(b.config.OutputDir, visit); err != nil {
return nil, err
}
artifact := &Artifact{
dir: b.config.OutputDir,
f: files,
}
return artifact, nil
}
func (b *Builder) Cancel() {