-
Notifications
You must be signed in to change notification settings - Fork 776
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
Added a time_add() filter to add duration and absolute time #5817
Conversation
Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com>
Codecov Report
@@ Coverage Diff @@
## main #5817 +/- ##
==========================================
+ Coverage 35.75% 35.85% +0.10%
==========================================
Files 188 188
Lines 20884 20954 +70
==========================================
+ Hits 7467 7513 +46
- Misses 12598 12614 +16
- Partials 819 827 +8
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I don't really like the format argument, how about a |
+1, |
The arguments here are similar to |
IMHO we should support only one format internally and use conversion when input is in another format. |
pkg/engine/jmespath/functions.go
Outdated
@@ -461,6 +462,18 @@ func GetFunctions() []*FunctionEntry { | |||
ReturnType: []JpType{JpObject}, | |||
Note: "decodes an x.509 certificate to an object. you may also use this in conjunction with `base64_decode` jmespath function to decode a base64-encoded certificate", | |||
}, | |||
{ |
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.
@vishal-chdhry can you add a note to the function descriptor ?
@vishal-chdhry - can you address comment here? We'd like to get this merged to 1.9 and cut beta.2 by Friday. |
Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com>
@realshuting @eddycharly done! |
Thanks for these, @vishal-chdhry ! |
Thanks @vishal-chdhry ! We were discussing the possibility to add a |
@eddycharly I can add it to this PR |
@vishal-chdhry it would be awesome ❤️ |
Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com>
should I convert the times to utc or keep the given timezone? (currently |
@vishal-chdhry isn't it covered by the format ?
we don't want to change |
expectedResult string | ||
}{ | ||
{ | ||
test: "time_convert('', '2021-01-02T15:04:05-07:00')", |
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.
Does it make sense to call time_convert
with an empty format ?
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.
empty string everywhere else means we are using RFC3339, I kept it for consistency
and if the layout is empty and the time isn't in RFC3339 format then it will throw an error
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.
I understand the idea but why one would call time_convert
if the input is already in RFC3339 ?
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.
I would rather not default the format, sounds error prone.
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.
ok, I should remove it then
@eddycharly time.format() doesn't change the timezone to UTC, for example, in the first test case |
what are the pros/cons of converting to UTC ? do you have an opinion @JimBugwadia @chipzoller @realshuting ? |
@vishal-chdhry what would be the best name |
@eddycharly |
Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com>
Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com>
The pros are pretty clear:
Cons are less clear but seem to be few from what I can think of. |
IMHO it's better to not enforce UTC. |
@vishal-chdhry can you resolve conflicts ? |
Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com>
@eddycharly Done! |
One thing I ran into testing CronJobs is to be mindful that the cron format given is interpreted by the time zone of the Node on which the Pod will execute. In 1.26 there's a way to specify a time zone, but that's obviously not something we can adopt ourselves now. |
@chipzoller IIRC it's the TZ of the master nodes, not the TZ of the node where the pod executes. |
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.
Good job @vishal-chdhry !
/cherry-pick release-1.9 |
2 similar comments
/cherry-pick release-1.9 |
/cherry-pick release-1.9 |
…#5817) * time_add Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * output is RFC3339 only now Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * added note to timeadd Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * added time_convert Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * removed blank string timezone Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * renamed to time_parse Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> Co-authored-by: shuting <shuting@nirmata.com> Co-authored-by: Charles-Edouard Brétéché <charled.breteche@gmail.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
…5946) * time_add Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * output is RFC3339 only now Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * added note to timeadd Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * added time_convert Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * removed blank string timezone Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * renamed to time_parse Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> Co-authored-by: shuting <shuting@nirmata.com> Co-authored-by: Charles-Edouard Brétéché <charled.breteche@gmail.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Co-authored-by: Vishal Choudhary <contactvishaltech@gmail.com> Co-authored-by: shuting <shuting@nirmata.com>
…#5817) * time_add Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * output is RFC3339 only now Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * added note to timeadd Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * added time_convert Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * removed blank string timezone Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * renamed to time_parse Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> Co-authored-by: shuting <shuting@nirmata.com> Co-authored-by: Charles-Edouard Brétéché <charled.breteche@gmail.com> Signed-off-by: MdSahil-oss <Mohdssahil1@gmail.com>
…#5817) * time_add Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * output is RFC3339 only now Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * added note to timeadd Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * added time_convert Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * removed blank string timezone Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * renamed to time_parse Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> Co-authored-by: shuting <shuting@nirmata.com> Co-authored-by: Charles-Edouard Brétéché <charled.breteche@gmail.com> Signed-off-by: MdSahil-oss <Mohdssahil1@gmail.com>
…#5817) * time_add Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * output is RFC3339 only now Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * added note to timeadd Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * added time_convert Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * removed blank string timezone Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> * renamed to time_parse Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com> Co-authored-by: shuting <shuting@nirmata.com> Co-authored-by: Charles-Edouard Brétéché <charled.breteche@gmail.com> Signed-off-by: MdSahil-oss <Mohdssahil1@gmail.com>
Signed-off-by: Vishal Choudhary contactvishaltech@gmail.com
Explanation
Adds a custom JMESPath filter to support inputs in the form of RFC3339 + scalar (duration) with the sum being RFC3339.
Related issue
Closes #5815
Milestone of this PR
What type of PR is this
/kind feature
Proposed Changes
Proof Manifests
Checklist
Further Comments