-
Notifications
You must be signed in to change notification settings - Fork 7
/
artifact.go
54 lines (44 loc) · 1.03 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
46
47
48
49
50
51
52
53
54
package upcloud
import (
"fmt"
"strings"
"github.com/UpCloudLtd/packer-plugin-upcloud/internal/driver"
"github.com/UpCloudLtd/upcloud-go-api/v4/upcloud"
)
// packersdk.Artifact implementation
type Artifact struct {
config *Config
driver driver.Driver
Templates []*upcloud.Storage
// StateData should store data such as GeneratedData
// to be shared with post-processors
StateData map[string]interface{}
}
func (*Artifact) BuilderId() string {
return BuilderId
}
func (a *Artifact) Files() []string {
return []string{}
}
func (a *Artifact) Id() string {
result := []string{}
for _, t := range a.Templates {
result = append(result, t.UUID)
}
return strings.Join(result, ",")
}
func (a *Artifact) String() string {
return fmt.Sprintf("Storage template created, UUID: %s", a.Id())
}
func (a *Artifact) State(name string) interface{} {
return a.StateData[name]
}
func (a *Artifact) Destroy() error {
for _, t := range a.Templates {
err := a.driver.DeleteTemplate(t.UUID)
if err != nil {
return err
}
}
return nil
}