mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
octodns-dump support all zones, including dynamic-config
This commit is contained in:
@@ -39,7 +39,10 @@ def main():
|
||||
default=False,
|
||||
help='Split the dumped zone into a YAML file per record',
|
||||
)
|
||||
parser.add_argument('zone', help='Zone to dump')
|
||||
parser.add_argument(
|
||||
'zone',
|
||||
help="Zone to dump, '*' (single quoted to avoid expansion) for all configured zones",
|
||||
)
|
||||
parser.add_argument('source', nargs='+', help='Source(s) to pull data from')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
+18
-7
@@ -851,14 +851,25 @@ class Manager(object):
|
||||
clz = SplitYamlProvider
|
||||
target = clz('dump', output_dir)
|
||||
|
||||
zone = self.get_zone(zone)
|
||||
for source in sources:
|
||||
source.populate(zone, lenient=lenient)
|
||||
zones = self.config['zones']
|
||||
zones = self._preprocess_zones(zones, [s.id for s in sources])
|
||||
|
||||
plan = target.plan(zone)
|
||||
if plan is None:
|
||||
plan = Plan(zone, zone, [], False)
|
||||
target.apply(plan)
|
||||
if '*' in zone:
|
||||
# we want to do everything, just need the names though
|
||||
zones = zones.keys()
|
||||
else:
|
||||
# we want to do a specific zone
|
||||
zones = [zone]
|
||||
|
||||
for zone in zones:
|
||||
zone = self.get_zone(zone)
|
||||
for source in sources:
|
||||
source.populate(zone, lenient=lenient)
|
||||
|
||||
plan = target.plan(zone)
|
||||
if plan is None:
|
||||
plan = Plan(zone, zone, [], False)
|
||||
target.apply(plan)
|
||||
|
||||
def validate_configs(self):
|
||||
# TODO: this code can probably be shared with stuff in sync
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from os import environ
|
||||
from os import environ, listdir
|
||||
from os.path import dirname, isfile, join
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock, patch
|
||||
@@ -371,12 +371,28 @@ class TestManager(TestCase):
|
||||
)
|
||||
self.assertEqual('Unknown source: nope', str(ctx.exception))
|
||||
|
||||
# specific zone
|
||||
manager.dump(
|
||||
zone='unit.tests.',
|
||||
output_dir=tmpdir.dirname,
|
||||
split=True,
|
||||
sources=['in'],
|
||||
)
|
||||
self.assertEqual(['unit.tests.'], listdir(tmpdir.dirname))
|
||||
|
||||
# all configured zones
|
||||
manager.dump(
|
||||
zone='*', output_dir=tmpdir.dirname, split=True, sources=['in']
|
||||
)
|
||||
self.assertEqual(
|
||||
[
|
||||
'empty.',
|
||||
'sub.txt.unit.tests.',
|
||||
'subzone.unit.tests.',
|
||||
'unit.tests.',
|
||||
],
|
||||
sorted(listdir(tmpdir.dirname)),
|
||||
)
|
||||
|
||||
# make sure this fails with an ManagerException and not a KeyError
|
||||
# when trying to find sub zones
|
||||
|
||||
Reference in New Issue
Block a user