Browse Source

Fix zone-level always-dry-run functionality

Thanks @offmindby!
pull/60/head
Ross McFarland 9 years ago
parent
commit
371138dbec
2 changed files with 15 additions and 1 deletions
  1. +7
    -1
      octodns/manager.py
  2. +8
    -0
      tests/test_octodns_manager.py

+ 7
- 1
octodns/manager.py View File

@ -273,12 +273,18 @@ class Manager(object):
for target, plan in plans: for target, plan in plans:
plan.raise_if_unsafe() plan.raise_if_unsafe()
if dry_run or config.get('always-dry-run', False):
if dry_run:
return 0 return 0
total_changes = 0 total_changes = 0
self.log.debug('sync: applying') self.log.debug('sync: applying')
zones = self.config['zones']
for target, plan in plans: for target, plan in plans:
zone_name = plan.existing.name
if zones[zone_name].get('always-dry-run', False):
self.log.info('sync: zone=%s skipping always-dry-run',
zone_name)
continue
total_changes += target.apply(plan) total_changes += target.apply(plan)
self.log.info('sync: %d total changes', total_changes) self.log.info('sync: %d total changes', total_changes)


+ 8
- 0
tests/test_octodns_manager.py View File

@ -88,6 +88,14 @@ class TestManager(TestCase):
.sync(['not.targetable.']) .sync(['not.targetable.'])
self.assertTrue('does not support targeting' in ctx.exception.message) self.assertTrue('does not support targeting' in ctx.exception.message)
def test_always_dry_run(self):
with TemporaryDirectory() as tmpdir:
environ['YAML_TMP_DIR'] = tmpdir.dirname
tc = Manager(get_config_filename('always-dry-run.yaml')) \
.sync(dry_run=False)
# only the stuff from subzone, unit.tests. is always-dry-run
self.assertEquals(3, tc)
def test_simple(self): def test_simple(self):
with TemporaryDirectory() as tmpdir: with TemporaryDirectory() as tmpdir:
environ['YAML_TMP_DIR'] = tmpdir.dirname environ['YAML_TMP_DIR'] = tmpdir.dirname


Loading…
Cancel
Save