packer-cn/artifact.go

48 lines
694 B
Go
Raw Normal View History

package main
2017-06-29 18:08:49 -04:00
import (
"github.com/vmware/govmomi/object"
"context"
)
2017-06-27 03:55:49 -04:00
const BuilderId = "jetbrains.vsphere"
type Artifact struct {
2017-06-29 18:08:49 -04:00
VMName string
Conn *object.VirtualMachine
}
func (a *Artifact) BuilderId() string {
return BuilderId
}
func (a *Artifact) Files() []string {
return []string{}
}
func (a *Artifact) Id() string {
return a.VMName
}
func (a *Artifact) String() string {
return a.VMName
}
func (a *Artifact) State(name string) interface{} {
return nil
}
func (a *Artifact) Destroy() error {
2017-06-29 18:08:49 -04:00
ctx := context.TODO()
task, err := a.Conn.Destroy(ctx)
if err != nil {
return err
}
_, err = task.WaitForResult(ctx, nil)
if err != nil {
return err
}
return nil
}