github.com/sneal/packer@v0.5.2/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 ID of the region 19 regionId uint 20 21 // The client for making API calls 22 client *DigitalOceanClient 23 } 24 25 func (*Artifact) BuilderId() string { 26 return BuilderId 27 } 28 29 func (*Artifact) Files() []string { 30 // No files with DigitalOcean 31 return nil 32 } 33 34 func (a *Artifact) Id() string { 35 // mimicing the aws builder 36 return fmt.Sprintf("%s:%s", a.regionName, a.snapshotName) 37 } 38 39 func (a *Artifact) String() string { 40 return fmt.Sprintf("A snapshot was created: '%v' in region '%v'", a.snapshotName, a.regionName) 41 } 42 43 func (a *Artifact) Destroy() error { 44 log.Printf("Destroying image: %d (%s)", a.snapshotId, a.snapshotName) 45 return a.client.DestroyImage(a.snapshotId) 46 }