github.com/daniellockard/packer@v0.7.6-0.20141210173435-5a9390934716/builder/digitalocean/artifact.go (about)

     1  package digitalocean
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  	"strconv"
     7  )
     8  
     9  type Artifact struct {
    10  	// The name of the snapshot
    11  	snapshotName string
    12  
    13  	// The ID of the image
    14  	snapshotId uint
    15  
    16  	// The name of the region
    17  	regionName string
    18  
    19  	// The client for making API calls
    20  	client DigitalOceanClient
    21  }
    22  
    23  func (*Artifact) BuilderId() string {
    24  	return BuilderId
    25  }
    26  
    27  func (*Artifact) Files() []string {
    28  	// No files with DigitalOcean
    29  	return nil
    30  }
    31  
    32  func (a *Artifact) Id() string {
    33  	return strconv.FormatUint(uint64(a.snapshotId), 10)
    34  }
    35  
    36  func (a *Artifact) String() string {
    37  	return fmt.Sprintf("A snapshot was created: '%v' in region '%v'", a.snapshotName, a.regionName)
    38  }
    39  
    40  func (a *Artifact) State(name string) interface{} {
    41  	return nil
    42  }
    43  
    44  func (a *Artifact) Destroy() error {
    45  	log.Printf("Destroying image: %d (%s)", a.snapshotId, a.snapshotName)
    46  	return a.client.DestroyImage(a.snapshotId)
    47  }