From ee517587a9045848b0cfc7b3f41fe64857a5cdfd Mon Sep 17 00:00:00 2001 From: Viranch Mehta Date: Tue, 21 Sep 2021 02:04:52 -0700 Subject: [PATCH] add validation for status flag --- octodns/record/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/octodns/record/__init__.py b/octodns/record/__init__.py index ba8e3c6..f24a89e 100644 --- a/octodns/record/__init__.py +++ b/octodns/record/__init__.py @@ -418,7 +418,7 @@ class _DynamicPool(object): { 'value': d['value'], 'weight': d.get('weight', 1), - 'status': d.get('status', 'obey'), # TODO: add validation on this field + 'status': d.get('status', 'obey'), } for d in data['values'] ] values.sort(key=lambda d: d['value']) @@ -574,6 +574,14 @@ class _DynamicMixin(object): reasons.append(f'missing value in pool "{_id}" ' f'value {value_num}') + try: + status = value['status'] + if status not in ['up', 'down', 'obey']: + reasons.append(f'invalid status "{status}" in ' + f'pool "{_id}" value {value_num}') + except KeyError: + pass + if len(values) == 1 and values[0].get('weight', 1) != 1: reasons.append(f'pool "{_id}" has single value with ' 'weight!=1')