diff --git a/builder/vmware/common/artifact.go b/builder/vmware/common/artifact.go index 48fcb8139..e0b3e875e 100644 --- a/builder/vmware/common/artifact.go +++ b/builder/vmware/common/artifact.go @@ -14,13 +14,14 @@ const BuilderId = "mitchellh.vmware" // Artifact is the result of running the VMware builder, namely a set // of files associated with the resulting machine. type localArtifact struct { + id string dir string f []string } // NewLocalArtifact returns a VMware artifact containing the files // in the given directory. -func NewLocalArtifact(dir string) (packer.Artifact, error) { +func NewLocalArtifact(id string, dir string) (packer.Artifact, error) { files := make([]string, 0, 5) visit := func(path string, info os.FileInfo, err error) error { if err != nil { @@ -37,6 +38,7 @@ func NewLocalArtifact(dir string) (packer.Artifact, error) { } return &localArtifact{ + id: id, dir: dir, f: files, }, nil @@ -50,8 +52,8 @@ func (a *localArtifact) Files() []string { return a.f } -func (*localArtifact) Id() string { - return "VM" +func (a *localArtifact) Id() string { + return a.id } func (a *localArtifact) String() string { diff --git a/builder/vmware/common/artifact_test.go b/builder/vmware/common/artifact_test.go index e081cc358..53b8364f1 100644 --- a/builder/vmware/common/artifact_test.go +++ b/builder/vmware/common/artifact_test.go @@ -29,7 +29,7 @@ func TestNewLocalArtifact(t *testing.T) { t.Fatalf("err: %s", err) } - a, err := NewLocalArtifact(td) + a, err := NewLocalArtifact("vm1", td) if err != nil { t.Fatalf("err: %s", err) } @@ -37,6 +37,9 @@ func TestNewLocalArtifact(t *testing.T) { if a.BuilderId() != BuilderId { t.Fatalf("bad: %#v", a.BuilderId()) } + if a.Id() != "vm1" { + t.Fatalf("bad: %#v", a.Id()) + } if len(a.Files()) != 1 { t.Fatalf("should length 1: %d", len(a.Files())) } diff --git a/builder/vmware/iso/artifact.go b/builder/vmware/iso/artifact.go index d0e1a6d8b..a0c3ceace 100644 --- a/builder/vmware/iso/artifact.go +++ b/builder/vmware/iso/artifact.go @@ -8,6 +8,7 @@ import ( // of files associated with the resulting machine. type Artifact struct { builderId string + id string dir OutputDir f []string } @@ -20,8 +21,8 @@ func (a *Artifact) Files() []string { return a.f } -func (*Artifact) Id() string { - return "VM" +func (a *Artifact) Id() string { + return a.id } func (a *Artifact) String() string { diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index 42038b96a..3567e26a2 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -349,6 +349,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe return &Artifact{ builderId: builderId, + id: b.config.VMName, dir: dir, f: files, }, nil diff --git a/builder/vmware/vmx/builder.go b/builder/vmware/vmx/builder.go index c5c1f10b7..894c3488a 100644 --- a/builder/vmware/vmx/builder.go +++ b/builder/vmware/vmx/builder.go @@ -142,7 +142,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe return nil, errors.New("Build was halted.") } - return vmwcommon.NewLocalArtifact(b.config.OutputDir) + return vmwcommon.NewLocalArtifact(b.config.VMName, b.config.OutputDir) } // Cancel.