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
|
// Artifact is the result of running the VMware builder, namely a set
|
||||||
// of files associated with the resulting machine.
|
// of files associated with the resulting machine.
|
||||||
type localArtifact struct {
|
type localArtifact struct {
|
||||||
|
id string
|
||||||
dir string
|
dir string
|
||||||
f []string
|
f []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLocalArtifact returns a VMware artifact containing the files
|
// NewLocalArtifact returns a VMware artifact containing the files
|
||||||
// in the given directory.
|
// 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)
|
files := make([]string, 0, 5)
|
||||||
visit := func(path string, info os.FileInfo, err error) error {
|
visit := func(path string, info os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -37,6 +38,7 @@ func NewLocalArtifact(dir string) (packer.Artifact, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return &localArtifact{
|
return &localArtifact{
|
||||||
|
id: id,
|
||||||
dir: dir,
|
dir: dir,
|
||||||
f: files,
|
f: files,
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -50,8 +52,8 @@ func (a *localArtifact) Files() []string {
|
||||||
return a.f
|
return a.f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*localArtifact) Id() string {
|
func (a *localArtifact) Id() string {
|
||||||
return "VM"
|
return a.id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *localArtifact) String() string {
|
func (a *localArtifact) String() string {
|
||||||
|
|
|
@ -29,7 +29,7 @@ func TestNewLocalArtifact(t *testing.T) {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
a, err := NewLocalArtifact(td)
|
a, err := NewLocalArtifact("vm1", td)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,9 @@ func TestNewLocalArtifact(t *testing.T) {
|
||||||
if a.BuilderId() != BuilderId {
|
if a.BuilderId() != BuilderId {
|
||||||
t.Fatalf("bad: %#v", a.BuilderId())
|
t.Fatalf("bad: %#v", a.BuilderId())
|
||||||
}
|
}
|
||||||
|
if a.Id() != "vm1" {
|
||||||
|
t.Fatalf("bad: %#v", a.Id())
|
||||||
|
}
|
||||||
if len(a.Files()) != 1 {
|
if len(a.Files()) != 1 {
|
||||||
t.Fatalf("should length 1: %d", len(a.Files()))
|
t.Fatalf("should length 1: %d", len(a.Files()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
// of files associated with the resulting machine.
|
// of files associated with the resulting machine.
|
||||||
type Artifact struct {
|
type Artifact struct {
|
||||||
builderId string
|
builderId string
|
||||||
|
id string
|
||||||
dir OutputDir
|
dir OutputDir
|
||||||
f []string
|
f []string
|
||||||
}
|
}
|
||||||
|
@ -20,8 +21,8 @@ func (a *Artifact) Files() []string {
|
||||||
return a.f
|
return a.f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Artifact) Id() string {
|
func (a *Artifact) Id() string {
|
||||||
return "VM"
|
return a.id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Artifact) String() string {
|
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{
|
return &Artifact{
|
||||||
builderId: builderId,
|
builderId: builderId,
|
||||||
|
id: b.config.VMName,
|
||||||
dir: dir,
|
dir: dir,
|
||||||
f: files,
|
f: files,
|
||||||
}, nil
|
}, 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 nil, errors.New("Build was halted.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return vmwcommon.NewLocalArtifact(b.config.OutputDir)
|
return vmwcommon.NewLocalArtifact(b.config.VMName, b.config.OutputDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cancel.
|
// Cancel.
|
||||||
|
|
Loading…
Reference in New Issue