Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide timeDuration helper function #62

Closed
endorama opened this issue Feb 23, 2023 · 4 comments
Closed

Provide timeDuration helper function #62

endorama opened this issue Feb 23, 2023 · 4 comments

Comments

@endorama
Copy link
Member

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
Copy link
Contributor

aspacca commented Mar 10, 2023

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
Copy link
Contributor

aspacca commented Mar 13, 2023

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
Copy link
Contributor

aspacca commented Mar 14, 2023

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

@endorama
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants