mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
6d9d3b7f4c
* fix: remove jmespath replace directive Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * master Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> --------- Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Co-authored-by: shuting <shuting@nirmata.com>
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package jmespath
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
gojmespath "github.com/kyverno/go-jmespath"
|
|
)
|
|
|
|
var (
|
|
jpObject = gojmespath.JpObject
|
|
jpString = gojmespath.JpString
|
|
jpNumber = gojmespath.JpNumber
|
|
jpArray = gojmespath.JpArray
|
|
jpArrayString = gojmespath.JpArrayString
|
|
jpAny = gojmespath.JpAny
|
|
jpBool = gojmespath.JpType("bool")
|
|
)
|
|
|
|
type (
|
|
jpType = gojmespath.JpType
|
|
argSpec = gojmespath.ArgSpec
|
|
)
|
|
|
|
type FunctionEntry struct {
|
|
gojmespath.FunctionEntry
|
|
Note string
|
|
ReturnType []jpType
|
|
}
|
|
|
|
func (f FunctionEntry) String() string {
|
|
if f.Name == "" {
|
|
return ""
|
|
}
|
|
var args []string
|
|
for _, a := range f.Arguments {
|
|
var aTypes []string
|
|
for _, t := range a.Types {
|
|
aTypes = append(aTypes, string(t))
|
|
}
|
|
args = append(args, strings.Join(aTypes, "|"))
|
|
}
|
|
var returnArgs []string
|
|
for _, ra := range f.ReturnType {
|
|
returnArgs = append(returnArgs, string(ra))
|
|
}
|
|
output := fmt.Sprintf("%s(%s) %s", f.Name, strings.Join(args, ", "), strings.Join(returnArgs, ","))
|
|
if f.Note != "" {
|
|
output += fmt.Sprintf(" (%s)", f.Note)
|
|
}
|
|
return output
|
|
}
|