apiserver: validate borrowing for flowcontrol API

This commit is contained in:
Abu Kashem
2022-10-07 17:03:06 -04:00
committed by Mike Spreitzer
parent ca949d5188
commit c5520d6ba2
2 changed files with 99 additions and 0 deletions

View File

@@ -388,6 +388,14 @@ func ValidateLimitedPriorityLevelConfiguration(lplc *flowcontrol.LimitedPriority
allErrs = append(allErrs, field.Invalid(fldPath.Child(getVersionedFieldNameForConcurrencyShares(requestGV)), lplc.NominalConcurrencyShares, "must be positive"))
}
allErrs = append(allErrs, ValidateLimitResponse(lplc.LimitResponse, fldPath.Child("limitResponse"))...)
if lplc.LendablePercent != nil && !(*lplc.LendablePercent >= 0 && *lplc.LendablePercent <= 100) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("lendablePercent"), *lplc.LendablePercent, "must be between 0 and 100, inclusive"))
}
if lplc.BorrowingLimitPercent != nil && *lplc.BorrowingLimitPercent < 0 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("borrowingLimitPercent"), *lplc.BorrowingLimitPercent, "if specified, must be a non-negative integer"))
}
return allErrs
}