mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Add --lenient flag to dump
This commit is contained in:
@@ -18,6 +18,9 @@ def main():
|
|||||||
parser.add_argument('--output-dir', required=True,
|
parser.add_argument('--output-dir', required=True,
|
||||||
help='The directory into which the results will be '
|
help='The directory into which the results will be '
|
||||||
'written (Note: will overwrite existing files)')
|
'written (Note: will overwrite existing files)')
|
||||||
|
parser.add_argument('--lenient', action='store_true', default=False,
|
||||||
|
help='Ignore record validations and do a best effort '
|
||||||
|
'dump')
|
||||||
parser.add_argument('zone', help='Zone to dump')
|
parser.add_argument('zone', help='Zone to dump')
|
||||||
parser.add_argument('source', nargs='+',
|
parser.add_argument('source', nargs='+',
|
||||||
help='Source(s) to pull data from')
|
help='Source(s) to pull data from')
|
||||||
@@ -25,7 +28,7 @@ def main():
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
manager = Manager(args.config_file)
|
manager = Manager(args.config_file)
|
||||||
manager.dump(args.zone, args.output_dir, *args.source)
|
manager.dump(args.zone, args.output_dir, args.lenient, *args.source)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ class Manager(object):
|
|||||||
|
|
||||||
return zb.changes(za, _AggregateTarget(a + b))
|
return zb.changes(za, _AggregateTarget(a + b))
|
||||||
|
|
||||||
def dump(self, zone, output_dir, source, *sources):
|
def dump(self, zone, output_dir, lenient, source, *sources):
|
||||||
'''
|
'''
|
||||||
Dump zone data from the specified source
|
Dump zone data from the specified source
|
||||||
'''
|
'''
|
||||||
@@ -342,7 +342,7 @@ class Manager(object):
|
|||||||
|
|
||||||
zone = Zone(zone, self.configured_sub_zones(zone))
|
zone = Zone(zone, self.configured_sub_zones(zone))
|
||||||
for source in sources:
|
for source in sources:
|
||||||
source.populate(zone)
|
source.populate(zone, lenient=lenient)
|
||||||
|
|
||||||
plan = target.plan(zone)
|
plan = target.plan(zone)
|
||||||
target.apply(plan)
|
target.apply(plan)
|
||||||
|
|||||||
@@ -195,15 +195,15 @@ class TestManager(TestCase):
|
|||||||
manager = Manager(get_config_filename('simple.yaml'))
|
manager = Manager(get_config_filename('simple.yaml'))
|
||||||
|
|
||||||
with self.assertRaises(Exception) as ctx:
|
with self.assertRaises(Exception) as ctx:
|
||||||
manager.dump('unit.tests.', tmpdir.dirname, 'nope')
|
manager.dump('unit.tests.', tmpdir.dirname, False, 'nope')
|
||||||
self.assertEquals('Unknown source: nope', ctx.exception.message)
|
self.assertEquals('Unknown source: nope', ctx.exception.message)
|
||||||
|
|
||||||
manager.dump('unit.tests.', tmpdir.dirname, 'in')
|
manager.dump('unit.tests.', tmpdir.dirname, False, 'in')
|
||||||
|
|
||||||
# make sure this fails with an IOError and not a KeyError when
|
# make sure this fails with an IOError and not a KeyError when
|
||||||
# tyring to find sub zones
|
# tyring to find sub zones
|
||||||
with self.assertRaises(IOError):
|
with self.assertRaises(IOError):
|
||||||
manager.dump('unknown.zone.', tmpdir.dirname, 'in')
|
manager.dump('unknown.zone.', tmpdir.dirname, False, 'in')
|
||||||
|
|
||||||
def test_validate_configs(self):
|
def test_validate_configs(self):
|
||||||
Manager(get_config_filename('simple-validate.yaml')).validate_configs()
|
Manager(get_config_filename('simple-validate.yaml')).validate_configs()
|
||||||
|
|||||||
Reference in New Issue
Block a user