packer-cn/builder/linode/artifact.go
Marques Johansson 99987c2d56 Add Linode Images builder
Packer Builder for [Linode Images](https://www.linode.com/docs/platform/disk-images/linode-images/)

Adds the following builder:

  * `linode`

Based on https://github.com/linode/packer-builder-linode (MPL/2)
(formerly maintained by @dradtke).  Includes website docs and tests.

Relates to #174, #3131
2019-04-15 20:40:59 -04:00

33 lines
689 B
Go

package linode
import (
"context"
"fmt"
"log"
"github.com/linode/linodego"
)
type Artifact struct {
ImageID string
ImageLabel string
Driver *linodego.Client
}
func (a Artifact) BuilderId() string { return BuilderID }
func (a Artifact) Files() []string { return nil }
func (a Artifact) Id() string { return a.ImageID }
func (a Artifact) String() string {
return fmt.Sprintf("Linode image: %s (%s)", a.ImageLabel, a.ImageID)
}
func (a Artifact) State(name string) interface{} { return nil }
func (a Artifact) Destroy() error {
log.Printf("Destroying image: %s (%s)", a.ImageID, a.ImageLabel)
err := a.Driver.DeleteImage(context.TODO(), a.ImageID)
return err
}