Repository navigation
Conversation
Since kyverno/kyverno#5544, add() and subtract() return a Types mismatch error when a number is mixed with a quantity or a duration, and subtracting two quantities returns a quantity. modulo() also accepts two quantities or two durations. Update the add, subtract and modulo tables and replace the note that said a number added to a duration counts as seconds. Signed-off-by: Myrian Koumgang <kmyriantek@gmail.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Update the add-demo fallback to a quantity-typed zero or another type-preserving fallback.
No open issues 🎉
What changed in this PR
This documentation-only pull request updates the JMESPath arithmetic filter reference to reflect Kyverno’s current type-handling behavior.
Changes:
- Restricts
add()to same-type operands and updates its example. - Adds quantity and duration support to the
modulo()table. - Corrects quantity output for
subtract(). - The
add-demoexample still uses a numeric fallback that can cause a type mismatch with quantities and should be updated.
| File | Description |
|---|---|
src/content/docs/docs/policy-types/cluster-policy/jmespath.md |
Corrects arithmetic filter input/output tables, examples, and related guidance. |
Review effort: Lite
Author
|
@aerosouund the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue
Closes #2211
Proposed Changes
The arithmetic tables on the JMESPath page still described the behavior from before kyverno/kyverno#5544:
add(): the table allowed mixing a number with a quantity or a duration, and a note said a number added to a duration counts as seconds. Both give aTypes mismatcherror now, so the table lists same-type inputs only and the note showsadd('1h', '5s')instead.subtract(): two quantities give a quantity (subtract('1Gi', '512Mi')is512Mi), not a number. The section's own example,10Miminus5Kigiving10235Ki, already says so.modulo(): two quantities or two durations work too (modulo('10Mi', '3Mi')is1Mi), so they're added to the table.I checked every row against Kyverno's JMESPath engine on
main. Thedivide()andmultiply()tables already match.Checklist