mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Make YamlProvider.SUPPORTS_ROOT_NS configurable, default True
This will result in less churn in tests for root NS support and allow us to enable/disable things easily as needed.
This commit is contained in:
@@ -106,13 +106,13 @@ class YamlProvider(BaseProvider):
|
||||
SUPPORTS_DYNAMIC = True
|
||||
SUPPORTS_POOL_VALUE_STATUS = True
|
||||
SUPPORTS_MULTIVALUE_PTR = True
|
||||
SUPPORTS_ROOT_NS = True
|
||||
SUPPORTS = set(('A', 'AAAA', 'ALIAS', 'CAA', 'CNAME', 'DNAME', 'LOC', 'MX',
|
||||
'NAPTR', 'NS', 'PTR', 'SSHFP', 'SPF', 'SRV', 'TXT',
|
||||
'URLFWD'))
|
||||
|
||||
def __init__(self, id, directory, default_ttl=3600, enforce_order=True,
|
||||
populate_should_replace=False, *args, **kwargs):
|
||||
populate_should_replace=False, supports_root_ns=True,
|
||||
*args, **kwargs):
|
||||
klass = self.__class__.__name__
|
||||
self.log = logging.getLogger(f'{klass}[{id}]')
|
||||
self.log.debug('__init__: id=%s, directory=%s, default_ttl=%d, '
|
||||
@@ -124,6 +124,11 @@ class YamlProvider(BaseProvider):
|
||||
self.default_ttl = default_ttl
|
||||
self.enforce_order = enforce_order
|
||||
self.populate_should_replace = populate_should_replace
|
||||
self.supports_root_ns = supports_root_ns
|
||||
|
||||
@property
|
||||
def SUPPORTS_ROOT_NS(self):
|
||||
return self.supports_root_ns
|
||||
|
||||
def _populate_from_file(self, filename, zone, lenient):
|
||||
with open(filename, 'r') as fh:
|
||||
|
||||
@@ -5,6 +5,7 @@ providers:
|
||||
dump:
|
||||
class: octodns.provider.yaml.YamlProvider
|
||||
directory: env/YAML_TMP_DIR
|
||||
supports_root_ns: False
|
||||
zones:
|
||||
unit.tests.:
|
||||
always-dry-run: true
|
||||
|
||||
@@ -5,6 +5,7 @@ providers:
|
||||
dump:
|
||||
class: octodns.provider.yaml.YamlProvider
|
||||
directory: env/YAML_TMP_DIR
|
||||
supports_root_ns: False
|
||||
geo:
|
||||
class: helpers.GeoProvider
|
||||
nosshfp:
|
||||
|
||||
@@ -7,6 +7,7 @@ providers:
|
||||
dump:
|
||||
class: octodns.provider.yaml.YamlProvider
|
||||
directory: env/YAML_TMP_DIR
|
||||
supports_root_ns: False
|
||||
zones:
|
||||
unit.tests.:
|
||||
sources:
|
||||
|
||||
@@ -7,11 +7,13 @@ providers:
|
||||
dump:
|
||||
class: octodns.provider.yaml.YamlProvider
|
||||
directory: env/YAML_TMP_DIR
|
||||
supports_root_ns: False
|
||||
# This is sort of ugly, but it shouldn't hurt anything. It'll just write out
|
||||
# the target file twice where it and dump are both used
|
||||
dump2:
|
||||
class: octodns.provider.yaml.YamlProvider
|
||||
directory: env/YAML_TMP_DIR
|
||||
supports_root_ns: False
|
||||
simple:
|
||||
class: helpers.SimpleProvider
|
||||
geo:
|
||||
|
||||
@@ -113,45 +113,45 @@ class TestManager(TestCase):
|
||||
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.assertEqual(4, tc)
|
||||
self.assertEqual(3, tc)
|
||||
|
||||
def test_simple(self):
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
environ['YAML_TMP_DIR'] = tmpdir.dirname
|
||||
tc = Manager(get_config_filename('simple.yaml')) \
|
||||
.sync(dry_run=False)
|
||||
self.assertEqual(30, tc)
|
||||
self.assertEqual(26, tc)
|
||||
|
||||
# try with just one of the zones
|
||||
tc = Manager(get_config_filename('simple.yaml')) \
|
||||
.sync(dry_run=False, eligible_zones=['unit.tests.'])
|
||||
self.assertEqual(21, tc)
|
||||
self.assertEqual(20, tc)
|
||||
|
||||
# the subzone, with 2 targets
|
||||
tc = Manager(get_config_filename('simple.yaml')) \
|
||||
.sync(dry_run=False, eligible_zones=['subzone.unit.tests.'])
|
||||
self.assertEqual(8, tc)
|
||||
self.assertEqual(6, tc)
|
||||
|
||||
# and finally the empty zone (only root NS)
|
||||
# and finally the empty zone
|
||||
tc = Manager(get_config_filename('simple.yaml')) \
|
||||
.sync(dry_run=False, eligible_zones=['empty.'])
|
||||
self.assertEqual(1, tc)
|
||||
self.assertEqual(0, tc)
|
||||
|
||||
# Again with force
|
||||
tc = Manager(get_config_filename('simple.yaml')) \
|
||||
.sync(dry_run=False, force=True)
|
||||
self.assertEqual(30, tc)
|
||||
self.assertEqual(26, tc)
|
||||
|
||||
# Again with max_workers = 1
|
||||
tc = Manager(get_config_filename('simple.yaml'), max_workers=1) \
|
||||
.sync(dry_run=False, force=True)
|
||||
self.assertEqual(30, tc)
|
||||
self.assertEqual(26, tc)
|
||||
|
||||
# Include meta
|
||||
tc = Manager(get_config_filename('simple.yaml'), max_workers=1,
|
||||
include_meta=True) \
|
||||
.sync(dry_run=False, force=True)
|
||||
self.assertEqual(34, tc)
|
||||
self.assertEqual(30, tc)
|
||||
|
||||
def test_eligible_sources(self):
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
|
||||
Reference in New Issue
Block a user