2018-01-24 06:04:39 -05:00
|
|
|
package common
|
2017-04-16 16:04:50 -04:00
|
|
|
|
2017-06-29 18:08:49 -04:00
|
|
|
import (
|
2020-04-30 15:22:57 -04:00
|
|
|
"os"
|
|
|
|
|
2020-01-07 19:59:31 -05:00
|
|
|
"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"
|
2017-04-16 16:04:50 -04:00
|
|
|
|
|
|
|
type Artifact struct {
|
2020-04-30 15:22:57 -04:00
|
|
|
Outconfig *OutputConfig
|
|
|
|
Name string
|
|
|
|
VM *driver.VirtualMachine
|
2020-01-30 05:27:58 -05:00
|
|
|
|
|
|
|
// StateData should store data such as GeneratedData
|
|
|
|
// to be shared with post-processors
|
|
|
|
StateData map[string]interface{}
|
2017-04-16 16:04:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Artifact) BuilderId() string {
|
|
|
|
return BuilderId
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Artifact) Files() []string {
|
2020-04-30 15:22:57 -04:00
|
|
|
if a.Outconfig != nil {
|
|
|
|
files, _ := a.Outconfig.ListFiles()
|
|
|
|
return files
|
|
|
|
}
|
2017-05-09 10:23:57 -04:00
|
|
|
return []string{}
|
2017-04-16 16:04:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Artifact) Id() string {
|
2017-07-02 16:29:50 -04:00
|
|
|
return a.Name
|
2017-04-16 16:04:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Artifact) String() string {
|
2017-07-02 16:29:50 -04:00
|
|
|
return a.Name
|
2017-04-16 16:04:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Artifact) State(name string) interface{} {
|
2020-01-30 05:27:58 -05:00
|
|
|
return a.StateData[name]
|
2017-04-16 16:04:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Artifact) Destroy() error {
|
2020-04-30 15:22:57 -04:00
|
|
|
if a.Outconfig != nil {
|
|
|
|
os.RemoveAll(a.Outconfig.OutputDir)
|
|
|
|
}
|
2018-05-06 17:26:04 -04:00
|
|
|
return a.VM.Destroy()
|
2017-04-16 16:04:50 -04:00
|
|
|
}
|