-
Notifications
You must be signed in to change notification settings - Fork 22
/
image.go
45 lines (36 loc) · 805 Bytes
/
image.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 ec2
import (
"fmt"
awsec2 "github.com/aws/aws-sdk-go/service/ec2"
)
type Image struct {
client imagesClient
id *string
identifier string
resourceTags resourceTags
}
func NewImage(client imagesClient, id *string, resourceTags resourceTags) Image {
return Image{
client: client,
id: id,
identifier: *id,
resourceTags: resourceTags,
}
}
func (i Image) Delete() error {
_, err := i.client.DeregisterImage(&awsec2.DeregisterImageInput{ImageId: i.id})
if err != nil {
return fmt.Errorf("Delete: %s", err)
}
err = i.resourceTags.Delete("image", *i.id)
if err != nil {
return fmt.Errorf("Delete tags: %s", err)
}
return nil
}
func (i Image) Name() string {
return i.identifier
}
func (i Image) Type() string {
return "EC2 Image"
}