Commit f851e56d authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/vmware: Artifacts implemented

parent 378a7320
package vmware
import "fmt"
// Artifact is the result of running the VMware 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)
}
package vmware
import (
"testing"
"github.com/mitchellh/packer/packer"
)
func TestArtifact_Impl(t *testing.T) {
var raw interface{}
raw = &Artifact{}
if _, ok := raw.(packer.Artifact); !ok {
t.Fatal("Artifact must be a proper artifact")
}
}
......@@ -7,6 +7,8 @@ import (
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log"
"os"
"path/filepath"
"time"
)
......@@ -114,7 +116,28 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook) packer.Artifact {
b.runner = &multistep.BasicRunner{Steps: steps}
b.runner.Run(state)
// If we were interrupted or cancelled, then just exit.
if _, ok := state[multistep.StateCancelled]; ok {
return nil
}
if _, ok := state[multistep.StateHalted]; ok {
return nil
}
// Compile the artifact list
files := make([]string, 0, 10)
visit := func(path string, info os.FileInfo, err error) error {
files = append(files, path)
return err
}
if err := filepath.Walk(b.config.OutputDir, visit); err != nil {
ui.Error(fmt.Sprintf("Error collecting result files: %s", err))
return nil
}
return &Artifact{b.config.OutputDir, files}
}
func (b *Builder) Cancel() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment