mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Fix err handling due to cel update
This commit is contained in:
parent
aa383570f0
commit
ed03e0955c
@ -185,14 +185,14 @@ func (s *Validator) validateExpressions(fldPath *field.Path, sts *schema.Structu
|
||||
// been bypassed. int-or-string is typed as dynamic and so bypasses compiler type checking.
|
||||
errs = append(errs, field.Invalid(fldPath, obj, fmt.Sprintf("'%v': call arguments did not match a supported operator, function or macro signature for rule: %v", err, ruleErrorString(rule))))
|
||||
} else if strings.HasPrefix(err.Error(), "operation cancelled: actual cost limit exceeded") {
|
||||
errs = append(errs, field.Invalid(fldPath, obj, fmt.Sprintf("'%v': call cost exceeds limit for rule: %v", err, ruleErrorString(rule))))
|
||||
errs = append(errs, field.Invalid(fldPath, obj, fmt.Sprintf("'%v': no further validation rules will be run due to call cost exceeds limit for rule: %v", err, ruleErrorString(rule))))
|
||||
return errs, -1
|
||||
} else {
|
||||
// no such key: {key}, index out of bounds: {index}, integer overflow, division by zero, ...
|
||||
errs = append(errs, field.Invalid(fldPath, obj, fmt.Sprintf("%v evaluating rule: %v", err, ruleErrorString(rule))))
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if evalResult != types.True {
|
||||
if len(rule.Message) != 0 {
|
||||
errs = append(errs, field.Invalid(fldPath, obj, rule.Message))
|
||||
|
@ -1721,7 +1721,7 @@ func TestValidationExpressions(t *testing.T) {
|
||||
}
|
||||
errs, _ = celValidator.Validate(field.NewPath("root"), &s, tt.obj, tt.costBudget)
|
||||
for _, err := range errs {
|
||||
if err.Type == field.ErrorTypeInvalid && strings.Contains(err.Error(), "call cost exceeds limit for rule") {
|
||||
if err.Type == field.ErrorTypeInvalid && strings.Contains(err.Error(), "no further validation rules will be run due to call cost exceeds limit for rule") {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user