mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
00387f1015
* fix: error management in jp functions Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix: add tests for jp arithmetic funcs Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> --------- Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
21 lines
699 B
Go
21 lines
699 B
Go
package jmespath
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
const (
|
|
errorPrefix = "JMESPath function '%s': "
|
|
invalidArgumentTypeError = errorPrefix + "%d argument is expected of %s type"
|
|
genericError = errorPrefix + "%s"
|
|
argOutOfBoundsError = errorPrefix + "%d argument is out of bounds (%d)"
|
|
zeroDivisionError = errorPrefix + "Zero divisor passed"
|
|
nonIntModuloError = errorPrefix + "Non-integer argument(s) passed for modulo"
|
|
typeMismatchError = errorPrefix + "Types mismatch"
|
|
)
|
|
|
|
func formatError(format string, function string, values ...interface{}) error {
|
|
args := []interface{}{function}
|
|
args = append(args, values...)
|
|
return fmt.Errorf(format, args...)
|
|
}
|