mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-06 07:57:07 +00:00
* Add a kyverno jp command to test jmespath expressions Signed-off-by: Sambhav Kothari <sambhavs.email@gmail.com> * Auto-generate custom function docs Signed-off-by: Sambhav Kothari <sambhavs.email@gmail.com> Co-authored-by: Jim Bugwadia <jim@nirmata.com>
18 lines
303 B
Go
18 lines
303 B
Go
package jmespath
|
|
|
|
import (
|
|
gojmespath "github.com/jmespath/go-jmespath"
|
|
)
|
|
|
|
func New(query string) (*gojmespath.JMESPath, error) {
|
|
jp, err := gojmespath.Compile(query)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
for _, function := range GetFunctions() {
|
|
jp.Register(function.Entry)
|
|
}
|
|
|
|
return jp, nil
|
|
}
|