2013-06-17 07:01:42 -04:00
|
|
|
package digitalocean
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2013-06-19 00:54:15 -04:00
|
|
|
"log"
|
2013-06-17 07:01:42 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type Artifact struct {
|
|
|
|
// The name of the snapshot
|
|
|
|
snapshotName string
|
2013-06-19 00:54:15 -04:00
|
|
|
|
|
|
|
// The ID of the image
|
|
|
|
snapshotId uint
|
|
|
|
|
|
|
|
// The client for making API calls
|
|
|
|
client *DigitalOceanClient
|
2013-06-17 07:01:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (*Artifact) BuilderId() string {
|
|
|
|
return BuilderId
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*Artifact) Files() []string {
|
|
|
|
// No files with DigitalOcean
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Artifact) Id() string {
|
|
|
|
return a.snapshotName
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Artifact) String() string {
|
|
|
|
return fmt.Sprintf("A snapshot was created: %v", a.snapshotName)
|
|
|
|
}
|
2013-06-18 19:01:14 -04:00
|
|
|
|
|
|
|
func (a *Artifact) Destroy() error {
|
2013-06-19 00:54:15 -04:00
|
|
|
log.Printf("Destroying image: %d", a.snapshotId)
|
|
|
|
return a.client.DestroyImage(a.snapshotId)
|
2013-06-18 19:01:14 -04:00
|
|
|
}
|