Brainstorming Custom Functions #153
springcomp
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This discussion is a blank canvas to brainstorm whether custom functions – as found in existing implementations – are worthy of consideration for inclusion into the set of builtin functions. This post will be edited along my though process.
I will focus on Custom Filters as implemented by Kyverno – one of the most complete set of custom functions I’m aware of.
Arithmetic operations
+
syntax−
syntax×
syntax÷
syntax%
syntaxThese are currently implemented as
arithmetic-expressions
in JMESPath Community.¹ Unis: an interesting use case is that all Kyverno’s arithmetic functions are unit-aware and perform the necessary conversions.
Object manipulation functions
items()
from_items()
¹ Extended usage: Kyverno’s
items
function behaves like JMESPath Community's. However, it also supports assigning arbitrary key names to the intermediate array, thus further transforming the initial input. It is a powerful filter that might only be replicated in JMESPath Community with a complex expression – if even possible.String manipulation functions
lower(a) == lower(b)
replace()
replace()
split()
lower()
upper()
trim()
[0:n]
string slice syntax¹ Limitations: JMESPath currently supports comparisons with numbers only. A common request is to extend comparison to other types.
Scratch pad
¹ Note
² Note
TODO: study Gorilla Stack fork as well.
History
Beta Was this translation helpful? Give feedback.
All reactions