forked from hashicorp/packer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
artifact.go
46 lines (35 loc) · 875 Bytes
/
artifact.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package digitalocean
import (
"fmt"
"log"
)
type Artifact struct {
// The name of the snapshot
snapshotName string
// The ID of the image
snapshotId uint
// The name of the region
regionName string
// The ID of the region
regionId uint
// The client for making API calls
client *DigitalOceanClient
}
func (*Artifact) BuilderId() string {
return BuilderId
}
func (*Artifact) Files() []string {
// No files with DigitalOcean
return nil
}
func (a *Artifact) Id() string {
// mimicing the aws builder
return fmt.Sprintf("%s:%s", a.regionName, a.snapshotName)
}
func (a *Artifact) String() string {
return fmt.Sprintf("A snapshot was created: '%v' in region '%v'", a.snapshotName, a.regionName)
}
func (a *Artifact) Destroy() error {
log.Printf("Destroying image: %d (%s)", a.snapshotId, a.snapshotName)
return a.client.DestroyImage(a.snapshotId)
}