Calle Pettersson 905869308d Split proxmox builder into a common part and iso/clone builders
Clone builder is still just a stub. Proof-of-concept for #9626

Signed-off-by: Calle Pettersson <calle@cape.nu>
2020-09-04 23:53:09 +02:00

50 lines
981 B
Go

package proxmox
import (
"fmt"
"log"
"strconv"
"github.com/Telmate/proxmox-api-go/proxmox"
"github.com/hashicorp/packer/packer"
)
type Artifact struct {
builderID string
templateID int
proxmoxClient *proxmox.Client
// StateData should store data such as GeneratedData
// to be shared with post-processors
StateData map[string]interface{}
}
// Artifact implements packer.Artifact
var _ packer.Artifact = &Artifact{}
func (a *Artifact) BuilderId() string {
return a.builderID
}
func (*Artifact) Files() []string {
return nil
}
func (a *Artifact) Id() string {
return strconv.Itoa(a.templateID)
}
func (a *Artifact) String() string {
return fmt.Sprintf("A template was created: %d", a.templateID)
}
func (a *Artifact) State(name string) interface{} {
return a.StateData[name]
}
func (a *Artifact) Destroy() error {
log.Printf("Destroying template: %d", a.templateID)
_, err := a.proxmoxClient.DeleteVm(proxmox.NewVmRef(a.templateID))
return err
}