Metadata API: Add simple threshold validation

Probably there could be future API calls that modify "threshold"
to a new value, but the problem is we don't have a clear idea
if they would exist and what exactly they will do.
That's why it makes sense to validate against the potential problems
we can imagine - in this case, is passing a threshold below 1.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
This commit is contained in:
Martin Vrachev 2021-06-15 18:06:31 +03:00
parent 2a5bfb9cac
commit 6c5d970799

View file

@ -506,6 +506,8 @@ def __init__(
f"keyids should be a list of unique strings,"
f" instead got {keyids}"
)
if threshold < 1:
raise ValueError("threshold should be at least 1!")
self.keyids = keyids_set
self.threshold = threshold
self.unrecognized_fields: Mapping[str, Any] = unrecognized_fields or {}