Merge pull request #715 from octodns/single-value-weight-validation

Add a validation requiring single value weight=1
This commit is contained in:
Ross McFarland
2021-05-17 17:26:15 -07:00
committed by GitHub
2 changed files with 32 additions and 1 deletions
+4
View File
@@ -573,6 +573,10 @@ class _DynamicMixin(object):
reasons.append('missing value in pool "{}" '
'value {}'.format(_id, value_num))
if len(values) == 1 and values[0].get('weight', 1) != 1:
reasons.append('pool "{}" has single value with '
'weight!=1'.format(_id))
fallback = pool.get('fallback', None)
if fallback is not None:
if fallback in pools:
+28 -1
View File
@@ -3412,7 +3412,7 @@ class TestDynamicRecords(TestCase):
self.assertEquals(['pool "one" is missing values'],
ctx.exception.reasons)
# pool valu not a dict
# pool value not a dict
a_data = {
'dynamic': {
'pools': {
@@ -3596,6 +3596,33 @@ class TestDynamicRecords(TestCase):
self.assertEquals(['invalid weight "foo" in pool "three" value 2'],
ctx.exception.reasons)
# single value with weight!=1
a_data = {
'dynamic': {
'pools': {
'one': {
'values': [{
'weight': 12,
'value': '6.6.6.6',
}],
},
},
'rules': [{
'pool': 'one',
}],
},
'ttl': 60,
'type': 'A',
'values': [
'1.1.1.1',
'2.2.2.2',
],
}
with self.assertRaises(ValidationError) as ctx:
Record.new(self.zone, 'bad', a_data)
self.assertEquals(['pool "one" has single value with weight!=1'],
ctx.exception.reasons)
# invalid fallback
a_data = {
'dynamic': {