elastic / elastic-integration-corpus-generator-tool

Command line tool used for generating events corpus dynamically given a specific integration
Other
21 stars 11 forks source link

Provide `timeDuration` helper function #62

Closed endorama closed 1 year ago

endorama commented 1 year ago

This issue stems from this comment

To avoid losing track of this as the PR gets merged lets use this issue to continue the discussion.

aspacca commented 1 year ago

template:

{{- $timeField := generate "timeField" }}
{{- $durationInSecond := generate "durationInSecond" }}
{{- $durationString := int64 $durationInSecond | duration }}
{{- $modifiedTime := $timeField | dateModify $durationString }}
{{ $timeField.Format "2006-01-02T15:04:05.999999Z07:00" }} | dateModify {{ $durationString }}
{{ $modifiedTime.Format "2006-01-02T15:04:05.999999Z07:00" }}

output:

2023-03-10T22:56:30.216696+09:00 | dateModify 14m59s
2023-03-10T23:11:29.216696+09:00

2023-03-10T23:27:25.216767+09:00 | dateModify 8m47s
2023-03-10T23:36:12.216767+09:00

2023-03-10T23:13:04.216802+09:00 | dateModify 14m28s
2023-03-10T23:27:32.216802+09:00

2023-03-10T23:05:37.216826+09:00 | dateModify 3m26s
2023-03-10T23:09:03.216826+09:00

2023-03-10T23:13:30.21685+09:00 | dateModify 9m47s
2023-03-10T23:23:17.21685+09:00

let's think about how we can reduce, with a function or something in the configuration, the following:

{{- $durationInSecond := generate "durationInSecond" }}
{{- $durationString := int64 $durationInSecond | duration }}
{{- $modifiedTime := $timeField | dateModify $durationString }}
aspacca commented 1 year ago

let's think about how we can reduce, with a function or something in the configuration, the following:

not really needed:

{{- $timeField := generate "timeField" }}
{{- $modifiedTime := $timeField | dateModify ( generate "durationInSecond" | int64 | duration ) }}
{{ $modifiedTime.Format "2006-01-02T15:04:05.999999Z07:00" }}
aspacca commented 1 year ago

I think we can indeed remove our custom timeDuration function, what do you think @endorama ?

endorama commented 1 year ago

Agree with removal, as we can leverage sprig functions. The only template using it at the moment is aws.vpcflow.

I'm going to close this issue (as it refers to adding it not to removing it :D) and proceed with removing timeDuration.