mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Fix zone-level always-dry-run functionality
Thanks @offmindby!
This commit is contained in:
@@ -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)
|
||||||
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user