mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Add support for zones aliases
This commit adds support for zones aliases. This allows to define one or
multiple zone as aliases of an existing zone without using workarounds
like simlinks and miltiple "zones" entries in the configuration file.
An alias zone is share all of its content with it parent zone, only the
name of the zone is different.
```
zones:
example.com.:
aliases:
- example.net.
- example.org.
sources:
- in
targets:
- out
```
Known issues:
- No documentation,
- Only the `octodns-sync` and `octodns-validate` commands supports
aliases zones at this time,
I added a loop in the manager init function which convert all alias
zone to "real" ones during config validation, however I'm not sure
this is the right approach. Comments welcome.
This commit is contained in:
17
tests/config/bad-zone-aliases.yaml
Normal file
17
tests/config/bad-zone-aliases.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
manager:
|
||||
max_workers: 2
|
||||
providers:
|
||||
in:
|
||||
class: octodns.provider.yaml.YamlProvider
|
||||
directory: tests/config
|
||||
dump:
|
||||
class: octodns.provider.yaml.YamlProvider
|
||||
directory: env/YAML_TMP_DIR
|
||||
zones:
|
||||
unit.tests.:
|
||||
aliases:
|
||||
- unit.tests.
|
||||
sources:
|
||||
- in
|
||||
targets:
|
||||
- dump
|
||||
17
tests/config/simple-aliases.yaml
Normal file
17
tests/config/simple-aliases.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
manager:
|
||||
max_workers: 2
|
||||
providers:
|
||||
in:
|
||||
class: octodns.provider.yaml.YamlProvider
|
||||
directory: tests/config
|
||||
dump:
|
||||
class: octodns.provider.yaml.YamlProvider
|
||||
directory: env/YAML_TMP_DIR
|
||||
zones:
|
||||
unit.tests.:
|
||||
aliases:
|
||||
- unit-alias.tests.
|
||||
sources:
|
||||
- in
|
||||
targets:
|
||||
- dump
|
||||
@@ -290,7 +290,8 @@ class TestManager(TestCase):
|
||||
pass
|
||||
|
||||
# This should be ok, we'll fall back to not passing it
|
||||
manager._populate_and_plan('unit.tests.', [NoLenient()], [])
|
||||
manager._populate_and_plan('unit.tests.', 'unit.tests.',
|
||||
[NoLenient()], [])
|
||||
|
||||
class NoZone(SimpleProvider):
|
||||
|
||||
@@ -299,7 +300,16 @@ class TestManager(TestCase):
|
||||
|
||||
# This will blow up, we don't fallback for source
|
||||
with self.assertRaises(TypeError):
|
||||
manager._populate_and_plan('unit.tests.', [NoZone()], [])
|
||||
manager._populate_and_plan('unit.tests.', 'unit.tests.',
|
||||
[NoZone()], [])
|
||||
|
||||
def test_zone_aliases(self):
|
||||
Manager(get_config_filename('simple-aliases.yaml')).validate_configs()
|
||||
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('bad-zone-aliases.yaml')) \
|
||||
.validate_configs()
|
||||
self.assertTrue('Invalid zone alias' in text_type(ctx.exception))
|
||||
|
||||
|
||||
class TestMainThreadExecutor(TestCase):
|
||||
|
||||
Reference in New Issue
Block a user