2017-04-16 16:04:50 -04:00
|
|
|
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"
|
2017-04-16 16:04:50 -04:00
|
|
|
|
|
|
|
type Artifact struct {
|
2017-06-29 18:08:49 -04:00
|
|
|
VMName string
|
|
|
|
Conn *object.VirtualMachine
|
2017-04-16 16:04:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Artifact) BuilderId() string {
|
|
|
|
return BuilderId
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Artifact) Files() []string {
|
2017-05-09 10:23:57 -04:00
|
|
|
return []string{}
|
2017-04-16 16:04:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Artifact) Id() string {
|
2017-05-09 10:23:57 -04:00
|
|
|
return a.VMName
|
2017-04-16 16:04:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Artifact) String() string {
|
2017-05-09 10:23:57 -04:00
|
|
|
return a.VMName
|
2017-04-16 16:04:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2017-04-16 16:04:50 -04:00
|
|
|
return nil
|
|
|
|
}
|