github.com/homburg/packer@v0.6.1-0.20140528012651-1dcaf1716848/builder/digitalocean/artifact.go (about)

     1  package digitalocean
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  )
     7  
     8  type Artifact struct {
     9  	// The name of the snapshot
    10  	snapshotName string
    11  
    12  	// The ID of the image
    13  	snapshotId uint
    14  
    15  	// The name of the region
    16  	regionName string
    17  
    18  	// The client for making API calls
    19  	client *DigitalOceanClient
    20  }
    21  
    22  func (*Artifact) BuilderId() string {
    23  	return BuilderId
    24  }
    25  
    26  func (*Artifact) Files() []string {
    27  	// No files with DigitalOcean
    28  	return nil
    29  }
    30  
    31  func (a *Artifact) Id() string {
    32  	// mimicing the aws builder
    33  	return fmt.Sprintf("%s:%s", a.regionName, a.snapshotName)
    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) Destroy() error {
    41  	log.Printf("Destroying image: %d (%s)", a.snapshotId, a.snapshotName)
    42  	return a.client.DestroyImage(a.snapshotId)
    43  }