forked from schubergphilis/packer-cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 3
/
artifact.go
49 lines (39 loc) · 946 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
47
48
49
package cloudstack
import (
"fmt"
"github.com/mindjiver/gopherstack"
"log"
"net/url"
)
type Artifact struct {
// The name of the template
templateName string
// The ID of the image
templateId string
// The client for making API calls
client *gopherstack.CloudstackClient
}
func (*Artifact) BuilderId() string {
return BuilderId
}
func (*Artifact) Files() []string {
// No local files created with Cloudstack.
return nil
}
func (a *Artifact) Id() string {
values := url.Values{}
values.Set("templateid", a.templateId)
return a.client.BaseURL + "?" + values.Encode()
}
func (a *Artifact) String() string {
return fmt.Sprintf("A template was created: UUID: %v - Name: %v",
a.templateId, a.templateName)
}
func (a *Artifact) State(name string) interface{} {
return nil
}
func (a *Artifact) Destroy() error {
log.Printf("Delete template: %s", a.templateId)
_, err := a.client.DeleteTemplate(a.templateId)
return err
}