1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

Merge branch 'main' into fix-multiple-dynamic-zones

This commit is contained in:
Viranch Mehta
2023-09-19 11:14:49 -07:00
6 changed files with 49 additions and 5 deletions

View File

@@ -1,3 +1,8 @@
## v1.1.2 - 2023-09-20 - Bunch more bug fixes
* Fix crash bug when using the YamlProvider with a directory that contains a
mix of split and non-split zone yamls. See https://github.com/octodns/octodns/issues/1066
## v1.1.1 - 2023-09-16 - Doh! Fix that one little thing
* Address a bug in the handling of loading auto-arpa manager configuration.

View File

@@ -278,8 +278,10 @@ class YamlProvider(BaseProvider):
f'Both UTF-8 "{utf8}" and IDNA "{idna}" exist for {zone.decoded_name}'
)
directory = utf8
else:
elif isdir(idna):
directory = idna
else:
return []
for filename in listdir(directory):
if filename.endswith('.yaml'):
@@ -294,8 +296,10 @@ class YamlProvider(BaseProvider):
f'Both UTF-8 "{utf8}" and IDNA "{idna}" exist for {zone.decoded_name}'
)
return utf8
elif isfile(idna):
return idna
return idna
return None
def _populate_from_file(self, filename, zone, lenient):
with open(filename, 'r') as fh:
@@ -341,11 +345,16 @@ class YamlProvider(BaseProvider):
sources.extend(self._split_sources(zone))
if not self.disable_zonefile:
sources.append(self._zone_sources(zone))
source = self._zone_sources(zone)
if source:
sources.append(source)
if self.shared_filename:
sources.append(join(self.directory, self.shared_filename))
if not sources:
raise ProviderException(f'no YAMLs found for {zone.decoded_name}')
# determinstically order our sources
sources.sort()

View File

@@ -0,0 +1,4 @@
---
flat-zone-file:
type: TXT
value: non-split flat zone file

View File

@@ -0,0 +1,4 @@
---
'':
type: TXT
value: root TXT

View File

@@ -0,0 +1,4 @@
---
split-zone-file:
type: TXT
value: split zone file

View File

@@ -663,8 +663,8 @@ class TestSplitYamlProvider(TestCase):
zone = Zone('empty.', [])
# without it we see everything
source.populate(zone)
self.assertEqual(0, len(zone.records))
with self.assertRaises(ProviderException):
source.populate(zone)
def test_unsorted(self):
source = SplitYamlProvider(
@@ -760,6 +760,24 @@ class TestSplitYamlProvider(TestCase):
sorted(provider.list_zones()),
)
def test_hybrid_directory(self):
source = YamlProvider(
'test',
join(dirname(__file__), 'config/hybrid'),
split_extension='.',
strict_supports=False,
)
# flat zone file only
zone = Zone('one.test.', [])
source.populate(zone)
self.assertEqual(1, len(zone.records))
# split zone only
zone = Zone('two.test.', [])
source.populate(zone)
self.assertEqual(2, len(zone.records))
class TestOverridingYamlProvider(TestCase):
def test_provider(self):