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_DYNAMIC = True
|
||||||
SUPPORTS_POOL_VALUE_STATUS = True
|
SUPPORTS_POOL_VALUE_STATUS = True
|
||||||
SUPPORTS_MULTIVALUE_PTR = True
|
SUPPORTS_MULTIVALUE_PTR = True
|
||||||
SUPPORTS_ROOT_NS = True
|
|
||||||
SUPPORTS = set(('A', 'AAAA', 'ALIAS', 'CAA', 'CNAME', 'DNAME', 'LOC', 'MX',
|
SUPPORTS = set(('A', 'AAAA', 'ALIAS', 'CAA', 'CNAME', 'DNAME', 'LOC', 'MX',
|
||||||
'NAPTR', 'NS', 'PTR', 'SSHFP', 'SPF', 'SRV', 'TXT',
|
'NAPTR', 'NS', 'PTR', 'SSHFP', 'SPF', 'SRV', 'TXT',
|
||||||
'URLFWD'))
|
'URLFWD'))
|
||||||
|
|
||||||
def __init__(self, id, directory, default_ttl=3600, enforce_order=True,
|
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__
|
klass = self.__class__.__name__
|
||||||
self.log = logging.getLogger(f'{klass}[{id}]')
|
self.log = logging.getLogger(f'{klass}[{id}]')
|
||||||
self.log.debug('__init__: id=%s, directory=%s, default_ttl=%d, '
|
self.log.debug('__init__: id=%s, directory=%s, default_ttl=%d, '
|
||||||
@@ -124,6 +124,11 @@ class YamlProvider(BaseProvider):
|
|||||||
self.default_ttl = default_ttl
|
self.default_ttl = default_ttl
|
||||||
self.enforce_order = enforce_order
|
self.enforce_order = enforce_order
|
||||||
self.populate_should_replace = populate_should_replace
|
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):
|
def _populate_from_file(self, filename, zone, lenient):
|
||||||
with open(filename, 'r') as fh:
|
with open(filename, 'r') as fh:
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ providers:
|
|||||||
dump:
|
dump:
|
||||||
class: octodns.provider.yaml.YamlProvider
|
class: octodns.provider.yaml.YamlProvider
|
||||||
directory: env/YAML_TMP_DIR
|
directory: env/YAML_TMP_DIR
|
||||||
|
supports_root_ns: False
|
||||||
zones:
|
zones:
|
||||||
unit.tests.:
|
unit.tests.:
|
||||||
always-dry-run: true
|
always-dry-run: true
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ providers:
|
|||||||
dump:
|
dump:
|
||||||
class: octodns.provider.yaml.YamlProvider
|
class: octodns.provider.yaml.YamlProvider
|
||||||
directory: env/YAML_TMP_DIR
|
directory: env/YAML_TMP_DIR
|
||||||
|
supports_root_ns: False
|
||||||
geo:
|
geo:
|
||||||
class: helpers.GeoProvider
|
class: helpers.GeoProvider
|
||||||
nosshfp:
|
nosshfp:
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ providers:
|
|||||||
dump:
|
dump:
|
||||||
class: octodns.provider.yaml.YamlProvider
|
class: octodns.provider.yaml.YamlProvider
|
||||||
directory: env/YAML_TMP_DIR
|
directory: env/YAML_TMP_DIR
|
||||||
|
supports_root_ns: False
|
||||||
zones:
|
zones:
|
||||||
unit.tests.:
|
unit.tests.:
|
||||||
sources:
|
sources:
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ providers:
|
|||||||
dump:
|
dump:
|
||||||
class: octodns.provider.yaml.YamlProvider
|
class: octodns.provider.yaml.YamlProvider
|
||||||
directory: env/YAML_TMP_DIR
|
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
|
# 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
|
# the target file twice where it and dump are both used
|
||||||
dump2:
|
dump2:
|
||||||
class: octodns.provider.yaml.YamlProvider
|
class: octodns.provider.yaml.YamlProvider
|
||||||
directory: env/YAML_TMP_DIR
|
directory: env/YAML_TMP_DIR
|
||||||
|
supports_root_ns: False
|
||||||
simple:
|
simple:
|
||||||
class: helpers.SimpleProvider
|
class: helpers.SimpleProvider
|
||||||
geo:
|
geo:
|
||||||
|
|||||||
@@ -113,45 +113,45 @@ class TestManager(TestCase):
|
|||||||
tc = Manager(get_config_filename('always-dry-run.yaml')) \
|
tc = Manager(get_config_filename('always-dry-run.yaml')) \
|
||||||
.sync(dry_run=False)
|
.sync(dry_run=False)
|
||||||
# only the stuff from subzone, unit.tests. is always-dry-run
|
# only the stuff from subzone, unit.tests. is always-dry-run
|
||||||
self.assertEqual(4, tc)
|
self.assertEqual(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
|
||||||
tc = Manager(get_config_filename('simple.yaml')) \
|
tc = Manager(get_config_filename('simple.yaml')) \
|
||||||
.sync(dry_run=False)
|
.sync(dry_run=False)
|
||||||
self.assertEqual(30, tc)
|
self.assertEqual(26, tc)
|
||||||
|
|
||||||
# try with just one of the zones
|
# try with just one of the zones
|
||||||
tc = Manager(get_config_filename('simple.yaml')) \
|
tc = Manager(get_config_filename('simple.yaml')) \
|
||||||
.sync(dry_run=False, eligible_zones=['unit.tests.'])
|
.sync(dry_run=False, eligible_zones=['unit.tests.'])
|
||||||
self.assertEqual(21, tc)
|
self.assertEqual(20, tc)
|
||||||
|
|
||||||
# the subzone, with 2 targets
|
# the subzone, with 2 targets
|
||||||
tc = Manager(get_config_filename('simple.yaml')) \
|
tc = Manager(get_config_filename('simple.yaml')) \
|
||||||
.sync(dry_run=False, eligible_zones=['subzone.unit.tests.'])
|
.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')) \
|
tc = Manager(get_config_filename('simple.yaml')) \
|
||||||
.sync(dry_run=False, eligible_zones=['empty.'])
|
.sync(dry_run=False, eligible_zones=['empty.'])
|
||||||
self.assertEqual(1, tc)
|
self.assertEqual(0, tc)
|
||||||
|
|
||||||
# Again with force
|
# Again with force
|
||||||
tc = Manager(get_config_filename('simple.yaml')) \
|
tc = Manager(get_config_filename('simple.yaml')) \
|
||||||
.sync(dry_run=False, force=True)
|
.sync(dry_run=False, force=True)
|
||||||
self.assertEqual(30, tc)
|
self.assertEqual(26, tc)
|
||||||
|
|
||||||
# Again with max_workers = 1
|
# Again with max_workers = 1
|
||||||
tc = Manager(get_config_filename('simple.yaml'), max_workers=1) \
|
tc = Manager(get_config_filename('simple.yaml'), max_workers=1) \
|
||||||
.sync(dry_run=False, force=True)
|
.sync(dry_run=False, force=True)
|
||||||
self.assertEqual(30, tc)
|
self.assertEqual(26, tc)
|
||||||
|
|
||||||
# Include meta
|
# Include meta
|
||||||
tc = Manager(get_config_filename('simple.yaml'), max_workers=1,
|
tc = Manager(get_config_filename('simple.yaml'), max_workers=1,
|
||||||
include_meta=True) \
|
include_meta=True) \
|
||||||
.sync(dry_run=False, force=True)
|
.sync(dry_run=False, force=True)
|
||||||
self.assertEqual(34, tc)
|
self.assertEqual(30, tc)
|
||||||
|
|
||||||
def test_eligible_sources(self):
|
def test_eligible_sources(self):
|
||||||
with TemporaryDirectory() as tmpdir:
|
with TemporaryDirectory() as tmpdir:
|
||||||
|
|||||||
Reference in New Issue
Block a user