Merge pull request #5187 from mkuzmin/vmware-artifactid
vmware: Publish artifact ID
This commit is contained in:
commit
cd11e4ff33
|
@ -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 {
|
||||
|
|
|
@ -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()))
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue