Skip to content

Commit

Permalink
update(plugins/cloudtrail): Fix a time comparison
Browse files Browse the repository at this point in the history
Time.Compare was added in go 1.20.

Signed-off-by: Gerald Combs <[email protected]>
  • Loading branch information
geraldcombs committed May 3, 2023
1 parent 70c8b9b commit 243adbc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugins/cloudtrail/pkg/cloudtrail/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ func (oCtx *PluginInstance) openS3(input string) error {
return fmt.Errorf(PluginName + " invalid interval: \"%s\": %s", oCtx.config.S3Interval, err.Error())

}
if !endTime.IsZero() && endTime.Compare(startTime) > 0 {
return fmt.Errorf(PluginName + " start time %s must be less than end time %s", startTime.Format(RFC3339Simple), endTime.Format(RFC3339Simple))
}

// CloudTrail logs have the format
// bucket_name/prefix_name/AWSLogs/Account ID/CloudTrail/region/YYYY/MM/DD/AccountID_CloudTrail_RegionName_YYYYMMDDTHHmmZ_UniqueString.json.gz
Expand Down Expand Up @@ -235,6 +232,9 @@ func (oCtx *PluginInstance) openS3(input string) error {
startTS = startTime.Format("20060102T0304")
if !endTime.IsZero() {
endTS = endTime.Format("20060102T0304")
if endTS < startTS {
return fmt.Errorf(PluginName + " start time %s must be less than end time %s", startTime.Format(RFC3339Simple), endTime.Format(RFC3339Simple))
}
}
} else {
// No region prefixes found, just use what we were given.
Expand Down

0 comments on commit 243adbc

Please sign in to comment.