mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Validate that dynamic rule goes are not reused
This commit is contained in:
@@ -271,7 +271,11 @@ class _DynamicMixin(object):
|
||||
# currently looking at, e.g. geo=NA-US and there was a
|
||||
# previous rule with NA
|
||||
for seen, where in geos_seen.items():
|
||||
if geo.startswith(seen):
|
||||
if geo == seen:
|
||||
reasons.append(
|
||||
f'rule {rule_num} targets geo {geo} which has previously been seen in rule {where}'
|
||||
)
|
||||
elif geo.startswith(seen):
|
||||
reasons.append(
|
||||
f'rule {rule_num} targets geo {geo} which is more specific than the previously seen {seen} in rule {where}'
|
||||
)
|
||||
|
||||
@@ -1299,6 +1299,7 @@ class TestRecordDynamic(TestCase):
|
||||
self.assertFalse(reasons)
|
||||
self.assertEqual({'sfo', 'iad'}, pools_seen)
|
||||
|
||||
# this one targets NA in rule 0 and then NA-Ca in rule 1
|
||||
pools = {'iad', 'sfo'}
|
||||
rules = [
|
||||
{'geos': ('AS', 'NA'), 'pool': 'sfo'},
|
||||
@@ -1312,6 +1313,7 @@ class TestRecordDynamic(TestCase):
|
||||
reasons,
|
||||
)
|
||||
|
||||
# this one targets NA and NA-US in rule 0
|
||||
pools = {'sfo'}
|
||||
rules = [{'geos': ('AS', 'NA-US', 'NA'), 'pool': 'sfo'}]
|
||||
reasons, pools_seen = _DynamicMixin._validate_rules(pools, rules)
|
||||
@@ -1321,3 +1323,15 @@ class TestRecordDynamic(TestCase):
|
||||
],
|
||||
reasons,
|
||||
)
|
||||
|
||||
# this one targets the same geo in multiple rules
|
||||
pools = {'iad', 'sfo'}
|
||||
rules = [
|
||||
{'geos': ('AS', 'NA'), 'pool': 'sfo'},
|
||||
{'geos': ('EU', 'NA'), 'pool': 'iad'},
|
||||
]
|
||||
reasons, pools_seen = _DynamicMixin._validate_rules(pools, rules)
|
||||
self.assertEqual(
|
||||
['rule 2 targets geo NA which has previously been seen in rule 1'],
|
||||
reasons,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user