Browse Source

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

pull/1069/head
Viranch Mehta 2 years ago
parent
commit
b6c37d500b
No known key found for this signature in database GPG Key ID: D83D1392AE9F93B4
6 changed files with 49 additions and 5 deletions
  1. +5
    -0
      CHANGELOG.md
  2. +12
    -3
      octodns/provider/yaml.py
  3. +4
    -0
      tests/config/hybrid/one.test.yaml
  4. +4
    -0
      tests/config/hybrid/two.test./$two.test.yaml
  5. +4
    -0
      tests/config/hybrid/two.test./split-zone-file.yaml
  6. +20
    -2
      tests/test_octodns_provider_yaml.py

+ 5
- 0
CHANGELOG.md 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.


+ 12
- 3
octodns/provider/yaml.py 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()


+ 4
- 0
tests/config/hybrid/one.test.yaml View File

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

+ 4
- 0
tests/config/hybrid/two.test./$two.test.yaml View File

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

+ 4
- 0
tests/config/hybrid/two.test./split-zone-file.yaml View File

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

+ 20
- 2
tests/test_octodns_provider_yaml.py 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):


Loading…
Cancel
Save