4
4
"context"
5
5
"fmt"
6
6
7
- "github.com/aws/aws-sdk-go/aws"
7
+ "github.com/gotidy/ptr"
8
+
8
9
"github.com/aws/aws-sdk-go/service/cloudwatchevents"
9
10
10
11
"github.com/ekristen/libnuke/pkg/registry"
@@ -56,9 +57,9 @@ func (l *CloudWatchEventsTargetLister) List(_ context.Context, o interface{}) ([
56
57
for _ , target := range targetResp .Targets {
57
58
resources = append (resources , & CloudWatchEventsTarget {
58
59
svc : svc ,
59
- ruleName : rule .Name ,
60
- targetID : target .Id ,
61
- busName : bus .Name ,
60
+ Name : rule .Name ,
61
+ TargetID : target .Id ,
62
+ BusName : bus .Name ,
62
63
})
63
64
}
64
65
}
@@ -69,30 +70,27 @@ func (l *CloudWatchEventsTargetLister) List(_ context.Context, o interface{}) ([
69
70
70
71
type CloudWatchEventsTarget struct {
71
72
svc * cloudwatchevents.CloudWatchEvents
72
- targetID * string
73
- ruleName * string
74
- busName * string
73
+ TargetID * string
74
+ Name * string
75
+ BusName * string
75
76
}
76
77
77
78
func (r * CloudWatchEventsTarget ) Remove (_ context.Context ) error {
78
- ids := []* string {r .targetID }
79
+ ids := []* string {r .TargetID }
79
80
_ , err := r .svc .RemoveTargets (& cloudwatchevents.RemoveTargetsInput {
80
81
Ids : ids ,
81
- Rule : r .ruleName ,
82
- EventBusName : r .busName ,
83
- Force : aws .Bool (true ),
82
+ Rule : r .Name ,
83
+ EventBusName : r .BusName ,
84
+ Force : ptr .Bool (true ),
84
85
})
85
86
return err
86
87
}
87
88
88
89
func (r * CloudWatchEventsTarget ) String () string {
89
90
// TODO: change this to IAM format rule -> target and mark as breaking change for filters
90
- return fmt .Sprintf ("Rule: %s Target ID: %s" , * r .ruleName , * r .targetID )
91
+ return fmt .Sprintf ("Rule: %s Target ID: %s" , * r .Name , * r .TargetID )
91
92
}
92
93
93
94
func (r * CloudWatchEventsTarget ) Properties () types.Properties {
94
- return types .NewProperties ().
95
- Set ("Name" , r .ruleName ).
96
- Set ("TargetID" , r .targetID ).
97
- Set ("BusName" , r .busName )
95
+ return types .NewPropertiesFromStruct (r )
98
96
}
0 commit comments