packer-cn/builder/vsphere/common/artifact.go

51 lines
875 B
Go
Raw Normal View History

package common
2017-06-29 18:08:49 -04:00
import (
"os"
"github.com/hashicorp/packer/builder/vsphere/driver"
2017-06-29 18:08:49 -04:00
)
2017-06-27 03:55:49 -04:00
const BuilderId = "jetbrains.vsphere"
type Artifact struct {
Outconfig *OutputConfig
Name string
VM *driver.VirtualMachine
// StateData should store data such as GeneratedData
// to be shared with post-processors
StateData map[string]interface{}
}
func (a *Artifact) BuilderId() string {
return BuilderId
}
func (a *Artifact) Files() []string {
if a.Outconfig != nil {
files, _ := a.Outconfig.ListFiles()
return files
}
return []string{}
}
func (a *Artifact) Id() string {
2017-07-02 16:29:50 -04:00
return a.Name
}
func (a *Artifact) String() string {
2017-07-02 16:29:50 -04:00
return a.Name
}
func (a *Artifact) State(name string) interface{} {
return a.StateData[name]
}
func (a *Artifact) Destroy() error {
if a.Outconfig != nil {
os.RemoveAll(a.Outconfig.OutputDir)
}
2018-05-06 17:26:04 -04:00
return a.VM.Destroy()
}