-
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
feat: add more time jmespath filters #5950
Conversation
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Codecov Report
@@ Coverage Diff @@
## main #5950 +/- ##
==========================================
+ Coverage 35.71% 35.85% +0.14%
==========================================
Files 188 189 +1
Lines 21043 21147 +104
==========================================
+ Hits 7515 7582 +67
- Misses 12699 12730 +31
- Partials 829 835 +6
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Couldn't |
|
Ok, so this is the replacement for |
@chipzoller yes, the goal is to deprecate |
Ok, so we need a deprecation notice printed if |
Probably in another PR, this is not going to be easy :( I'm trying to find a way to analyse the AST of a jmespath expression to get better validation but it's not easy, especially because we can have nest jmespath expressions. |
Since we're talking about a warning, we could start with being "dumb" and just looking for that as a substring anywhere. Not ideal but it's better than nothing. |
Detecting a function call should be relatively easy. |
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Signed-off-by: shuting <shutting06@gmail.com>
/cherry-pick release-1.9 |
Cherry-pick failed with |
Signed-off-by: ShutingZhao <shuting@nirmata.com>
* feat: add more time jmespath filters Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * add time_utc and time_now_utc Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * add time_diff Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * more time filters Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * Update pkg/engine/jmespath/functions.go Signed-off-by: shuting <shutting06@gmail.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: shuting <shutting06@gmail.com> Co-authored-by: shuting <shutting06@gmail.com>
* feat: add more time jmespath filters Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * add time_utc and time_now_utc Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * add time_diff Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * more time filters Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * Update pkg/engine/jmespath/functions.go Signed-off-by: shuting <shutting06@gmail.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: shuting <shutting06@gmail.com> Co-authored-by: shuting <shutting06@gmail.com> Signed-off-by: MdSahil-oss <Mohdssahil1@gmail.com>
* feat: add more time jmespath filters Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * add time_utc and time_now_utc Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * add time_diff Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * more time filters Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * Update pkg/engine/jmespath/functions.go Signed-off-by: shuting <shutting06@gmail.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: shuting <shutting06@gmail.com> Co-authored-by: shuting <shutting06@gmail.com> Signed-off-by: MdSahil-oss <Mohdssahil1@gmail.com>
* feat: add more time jmespath filters Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * add time_utc and time_now_utc Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * add time_diff Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * more time filters Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * Update pkg/engine/jmespath/functions.go Signed-off-by: shuting <shutting06@gmail.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: shuting <shutting06@gmail.com> Co-authored-by: shuting <shutting06@gmail.com> Signed-off-by: MdSahil-oss <Mohdssahil1@gmail.com>
Signed-off-by: Charles-Edouard Brétéché charles.edouard@nirmata.com
Explanation
This PR adds a couple more time related jmespath filters:
time_utc
time_now_utc
time_diff
(the ultimate replacement fortime_since
)time_before
time_after
time_between
time_truncate
I also took the opportunity to refactor existing funcs and restructure the package to put all time related filters in a separate file.
Proof manifests
time_utc('2023-02-02T15:04:05-07:00')
->2023-02-02T22:04:05Z
same as
time_now
but result is in UTCtime_diff('2021-01-02T15:04:05-07:00', '2021-01-10T03:14:05-07:00')
->180h10m0s