mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
add validation for status flag
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user