mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
8be4460668
* added to_boolean in JMESPath Filter Signed-off-by: Abhishek Sawan <sawanabhi157@gmail.com> * updated to_boolean JMESPath filter Signed-off-by: Abhishek Sawan <sawanabhi157@gmail.com> * updated to_boolean JMESPath filter with function registration Signed-off-by: Abhishek Sawan <sawanabhi157@gmail.com> * fixed to_boolean JMESPath filter with function registration Signed-off-by: Abhishek Sawan <sawanabhi157@gmail.com> * Update pkg/engine/jmespath/functions.go Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> --------- Signed-off-by: Abhishek Sawan <sawanabhi157@gmail.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Co-authored-by: Charles-Edouard Brétéché <charled.breteche@gmail.com> Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
19 lines
611 B
Go
19 lines
611 B
Go
package jmespath
|
|
|
|
import (
|
|
"reflect"
|
|
)
|
|
|
|
func validateArg(f string, arguments []interface{}, index int, expectedType reflect.Kind) (reflect.Value, error) {
|
|
if index >= len(arguments) {
|
|
return reflect.Value{}, formatError(argOutOfBoundsError, f, index+1, len(arguments))
|
|
}
|
|
if arguments[index] == nil {
|
|
return reflect.Value{}, formatError(invalidArgumentTypeError, f, index+1, expectedType.String())
|
|
}
|
|
arg := reflect.ValueOf(arguments[index])
|
|
if arg.Type().Kind() != expectedType {
|
|
return reflect.Value{}, formatError(invalidArgumentTypeError, f, index+1, expectedType.String())
|
|
}
|
|
return arg, nil
|
|
}
|