Skip to content

Commit 76177af

Browse files
committed
fix(cloudwatchlogs-loggroup): property RetentionInDays should always have a value
1 parent b8982b4 commit 76177af

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

resources/cloudwatchlogs-loggroups.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package resources
22

33
import (
44
"context"
5+
"github.com/gotidy/ptr"
56
"strings"
67
"time"
78

@@ -87,14 +88,19 @@ func (l *CloudWatchLogsLogGroupLister) List(_ context.Context, o interface{}) ([
8788
lastEvent = time.Unix(*logGroup.CreationTime/1000, 0)
8889
}
8990

91+
var retentionInDays int64
92+
if logGroup.RetentionInDays != nil {
93+
retentionInDays = ptr.ToInt64(logGroup.RetentionInDays)
94+
}
9095

9196
resources = append(resources, &CloudWatchLogsLogGroup{
92-
svc: svc,
93-
logGroup: logGroup,
94-
lastEvent: lastEvent.Format(time.RFC3339),
95-
tags: tagResp.Tags,
97+
svc: svc,
98+
logGroup: logGroup,
99+
lastEvent: lastEvent.Format(time.RFC3339),
100+
retentionInDays: retentionInDays,
101+
tags: tagResp.Tags,
96102
})
97-
}
103+
}
98104
if output.NextToken == nil {
99105
break
100106
}
@@ -106,10 +112,11 @@ func (l *CloudWatchLogsLogGroupLister) List(_ context.Context, o interface{}) ([
106112
}
107113

108114
type CloudWatchLogsLogGroup struct {
109-
svc *cloudwatchlogs.CloudWatchLogs
110-
logGroup *cloudwatchlogs.LogGroup
111-
lastEvent string
112-
tags map[string]*string
115+
svc *cloudwatchlogs.CloudWatchLogs
116+
logGroup *cloudwatchlogs.LogGroup
117+
lastEvent string
118+
retentionInDays int64
119+
tags map[string]*string
113120
}
114121

115122
func (f *CloudWatchLogsLogGroup) Remove(_ context.Context) error {
@@ -129,12 +136,10 @@ func (f *CloudWatchLogsLogGroup) Properties() types.Properties {
129136
Set("logGroupName", f.logGroup.LogGroupName).
130137
Set("CreatedTime", f.logGroup.CreationTime).
131138
Set("LastEvent", f.lastEvent).
132-
Set("RetentionInDays", f.logGroup.RetentionInDays)
133-
139+
Set("RetentionInDays", f.retentionInDays)
134140

135141
for k, v := range f.tags {
136142
properties.SetTag(&k, v)
137143
}
138144
return properties
139145
}
140-

0 commit comments

Comments
 (0)