forked from leonidlm/packer-builder-softlayer
/
artifact.go
45 lines (37 loc) · 1 KB
/
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
package softlayer
import (
"fmt"
"log"
)
// Artifact represents a Softlayer image as the result of a Packer build.
type Artifact struct {
imageName string
imageId string
datacenterName string
client *SoftlayerClient
}
// BuilderId returns the builder Id.
func (*Artifact) BuilderId() string {
return BuilderId
}
// Destroy destroys the Softlayer image represented by the artifact.
func (self *Artifact) Destroy() error {
log.Printf("Destroying image: %s", self.String())
err := self.client.destroyImage(self.imageId)
return err
}
// Files returns the files represented by the artifact.
func (*Artifact) Files() []string {
return nil
}
// Id returns the Softlayer image ID.
func (self *Artifact) Id() string {
return self.imageId
}
func (self *Artifact) State(name string) interface{} {
return nil
}
// String returns the string representation of the artifact.
func (self *Artifact) String() string {
return fmt.Sprintf("%s::%s (%s)", self.datacenterName, self.imageId, self.imageName)
}