-
Notifications
You must be signed in to change notification settings - Fork 14
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
Remove timeDuration #81
Conversation
a16ae0a
to
f9a9010
Compare
{{- $startOffset := generate "StartOffset" }} | ||
{{- $startOffsetInSecond := mul -1 1000000000 $startOffset }} | ||
{{- $startOffsetDuration := $startOffsetInSecond | int64 | duration}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$startOffsetInSecond
was indeed $startOffsetInNanosecond
(my bad :))
$startOffset
was multiplied 1000000000
because our timeDuration
expected nanoseconds, duration
from sprig expects seconds: so we need to use directly the value in $startOffset
(still multiplied by -1
since we want to subtract the value) is already the correct one.
Not sure if you prefer a oneliner or not, but this might work as well:
{{- $start := mul -1 $startOffset | int64 | duration | $end.Add }}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for noticing, I completely missed that.
I updated the template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my oneliner was wrong:
time.Time.Add
takes a time.Duration
, but duration
returns a string, so we must use dateModify
from sprig
{{- $start := $end | dateModify (mul -1 $startOffset | int64 | duration) }}
todo: let's add to CI to generate at least one event for all the templates
Following up on discussion in #62 this PR removes
timeDuration
helper function.The same functionality is provided by
sprig
. This:becomes