@@ -2,8 +2,10 @@ package resources
2
2
3
3
import (
4
4
"context"
5
+ "fmt"
6
+
7
+ "github.com/gotidy/ptr"
5
8
6
- "github.com/aws/aws-sdk-go-v2/aws"
7
9
"github.com/aws/aws-sdk-go-v2/service/apigateway"
8
10
9
11
"github.com/ekristen/libnuke/pkg/registry"
@@ -32,7 +34,7 @@ func (l *APIGatewayDomainNameLister) List(ctx context.Context, o interface{}) ([
32
34
var resources []resource.Resource
33
35
34
36
params := & apigateway.GetDomainNamesInput {
35
- Limit : aws .Int32 (100 ),
37
+ Limit : ptr .Int32 (100 ),
36
38
}
37
39
38
40
for {
@@ -43,18 +45,18 @@ func (l *APIGatewayDomainNameLister) List(ctx context.Context, o interface{}) ([
43
45
44
46
for i := range output .Items {
45
47
item := & output .Items [i ]
46
-
48
+
49
+ var tags map [string ]string
50
+
47
51
// Get tags for the domain
48
52
tagsOutput , err := svc .GetTags (ctx , & apigateway.GetTagsInput {
49
- ResourceArn : aws .String ("arn:aws:apigateway:" + opts .Config .Region + "::/domainnames/" + * item .DomainName ),
53
+ ResourceArn : ptr .String (fmt . Sprintf ( "arn:aws:apigateway:%s::/domainnames/%s" , opts .Config .Region , * item .DomainName ) ),
50
54
})
51
55
if err != nil {
52
- return nil , err
56
+ opts . Logger . WithError ( err ). Error ( "failed to get tags for domain" )
53
57
}
54
-
55
- tags := make (map [string ]string )
56
- for key , value := range tagsOutput .Tags {
57
- tags [key ] = value
58
+ if tagsOutput .Tags != nil {
59
+ tags = tagsOutput .Tags
58
60
}
59
61
60
62
resources = append (resources , & APIGatewayDomainName {
@@ -82,30 +84,19 @@ type APIGatewayDomainName struct {
82
84
Tags map [string ]string
83
85
}
84
86
85
- func (f * APIGatewayDomainName ) Remove (ctx context.Context ) error {
86
- _ , err := f .svc .DeleteDomainName (ctx , & apigateway.DeleteDomainNameInput {
87
- DomainName : f .DomainName ,
88
- DomainNameId : f .DomainNameID ,
87
+ func (r * APIGatewayDomainName ) Remove (ctx context.Context ) error {
88
+ _ , err := r .svc .DeleteDomainName (ctx , & apigateway.DeleteDomainNameInput {
89
+ DomainName : r .DomainName ,
90
+ DomainNameId : r .DomainNameID ,
89
91
})
90
92
91
93
return err
92
94
}
93
95
94
- func (f * APIGatewayDomainName ) Properties () types.Properties {
95
- properties := types .NewProperties ()
96
-
97
- // Add all tags with "tag:" prefix
98
- for key , value := range f .Tags {
99
- properties .Set ("tag:" + key , value )
100
- }
101
-
102
- // Add other properties
103
- properties .Set ("DomainName" , f .DomainName )
104
- properties .Set ("DomainNameID" , f .DomainNameID )
105
-
106
- return properties
96
+ func (r * APIGatewayDomainName ) Properties () types.Properties {
97
+ return types .NewPropertiesFromStruct (r )
107
98
}
108
99
109
- func (f * APIGatewayDomainName ) String () string {
110
- return * f .DomainName
111
- }
100
+ func (r * APIGatewayDomainName ) String () string {
101
+ return * r .DomainName
102
+ }
0 commit comments