2021-04-16 23:17:00 +00:00
|
|
|
package jmespath
|
|
|
|
|
|
|
|
import (
|
|
|
|
gojmespath "github.com/jmespath/go-jmespath"
|
2023-04-13 16:13:40 +00:00
|
|
|
"github.com/kyverno/kyverno/pkg/config"
|
2021-04-16 23:17:00 +00:00
|
|
|
)
|
|
|
|
|
2023-04-13 16:13:40 +00:00
|
|
|
func newJMESPath(configuration config.Configuration, query string) (*gojmespath.JMESPath, error) {
|
2021-04-16 23:17:00 +00:00
|
|
|
jp, err := gojmespath.Compile(query)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-04-13 16:13:40 +00:00
|
|
|
for _, function := range GetFunctions(configuration) {
|
2023-02-06 11:39:53 +00:00
|
|
|
jp.Register(function.FunctionEntry)
|
2021-04-16 23:17:00 +00:00
|
|
|
}
|
|
|
|
return jp, nil
|
|
|
|
}
|