mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Manager prints provider, processor, and plan_output versions for non-core modules when available
This commit is contained in:
@@ -115,10 +115,13 @@ class Manager(object):
|
|||||||
self.log.exception('Invalid provider class')
|
self.log.exception('Invalid provider class')
|
||||||
raise ManagerException(f'Provider {provider_name} is missing '
|
raise ManagerException(f'Provider {provider_name} is missing '
|
||||||
'class')
|
'class')
|
||||||
_class = self._get_named_class('provider', _class)
|
_class, module, version = self._get_named_class('provider', _class)
|
||||||
kwargs = self._build_kwargs(provider_config)
|
kwargs = self._build_kwargs(provider_config)
|
||||||
try:
|
try:
|
||||||
self.providers[provider_name] = _class(provider_name, **kwargs)
|
self.providers[provider_name] = _class(provider_name, **kwargs)
|
||||||
|
if not module.startswith('octodns.'):
|
||||||
|
self.log.info('__init__: provider=%s (%s %s)',
|
||||||
|
provider_name, module, version)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
self.log.exception('Invalid provider config')
|
self.log.exception('Invalid provider config')
|
||||||
raise ManagerException('Incorrect provider config for ' +
|
raise ManagerException('Incorrect provider config for ' +
|
||||||
@@ -133,11 +136,15 @@ class Manager(object):
|
|||||||
self.log.exception('Invalid processor class')
|
self.log.exception('Invalid processor class')
|
||||||
raise ManagerException(f'Processor {processor_name} is '
|
raise ManagerException(f'Processor {processor_name} is '
|
||||||
'missing class')
|
'missing class')
|
||||||
_class = self._get_named_class('processor', _class)
|
_class, module, version = self._get_named_class('processor',
|
||||||
|
_class)
|
||||||
kwargs = self._build_kwargs(processor_config)
|
kwargs = self._build_kwargs(processor_config)
|
||||||
try:
|
try:
|
||||||
self.processors[processor_name] = _class(processor_name,
|
self.processors[processor_name] = _class(processor_name,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
if not module.startswith('octodns.'):
|
||||||
|
self.log.info('__init__: processor=%s (%s %s)',
|
||||||
|
processor_name, module, version)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
self.log.exception('Invalid processor config')
|
self.log.exception('Invalid processor config')
|
||||||
raise ManagerException('Incorrect processor config for ' +
|
raise ManagerException('Incorrect processor config for ' +
|
||||||
@@ -177,11 +184,15 @@ class Manager(object):
|
|||||||
self.log.exception('Invalid plan_output class')
|
self.log.exception('Invalid plan_output class')
|
||||||
raise ManagerException(f'plan_output {plan_output_name} is '
|
raise ManagerException(f'plan_output {plan_output_name} is '
|
||||||
'missing class')
|
'missing class')
|
||||||
_class = self._get_named_class('plan_output', _class)
|
_class, module, version = self._get_named_class('plan_output',
|
||||||
|
_class)
|
||||||
kwargs = self._build_kwargs(plan_output_config)
|
kwargs = self._build_kwargs(plan_output_config)
|
||||||
try:
|
try:
|
||||||
self.plan_outputs[plan_output_name] = \
|
self.plan_outputs[plan_output_name] = \
|
||||||
_class(plan_output_name, **kwargs)
|
_class(plan_output_name, **kwargs)
|
||||||
|
if not module.startswith('octodns.'):
|
||||||
|
self.log.info('__init__: plan_output=%s (%s %s)',
|
||||||
|
plan_output_name, module, version)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
self.log.exception('Invalid plan_output config')
|
self.log.exception('Invalid plan_output config')
|
||||||
raise ManagerException('Incorrect plan_output config for ' +
|
raise ManagerException('Incorrect plan_output config for ' +
|
||||||
@@ -195,8 +206,9 @@ class Manager(object):
|
|||||||
self.log.exception('_get_{}_class: Unable to import '
|
self.log.exception('_get_{}_class: Unable to import '
|
||||||
'module %s', _class)
|
'module %s', _class)
|
||||||
raise ManagerException(f'Unknown {_type} class: {_class}')
|
raise ManagerException(f'Unknown {_type} class: {_class}')
|
||||||
|
version = getattr(module, '__VERSION__', 'n/a')
|
||||||
try:
|
try:
|
||||||
return getattr(module, class_name)
|
return getattr(module, class_name), module_name, version
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
self.log.exception('_get_{}_class: Unable to get class %s '
|
self.log.exception('_get_{}_class: Unable to get class %s '
|
||||||
'from module %s', class_name, module)
|
'from module %s', class_name, module)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
providers:
|
providers:
|
||||||
config:
|
config:
|
||||||
class: octodns.provider.yaml.YamlProvider
|
# This helps us get coverage when printing out provider versions
|
||||||
|
class: helpers.TestYamlProvider
|
||||||
directory: tests/config
|
directory: tests/config
|
||||||
dump:
|
dump:
|
||||||
class: octodns.provider.yaml.YamlProvider
|
class: octodns.provider.yaml.YamlProvider
|
||||||
@@ -15,6 +16,9 @@ processors:
|
|||||||
# Just testing config so any processor will do
|
# Just testing config so any processor will do
|
||||||
noop:
|
noop:
|
||||||
class: octodns.processor.base.BaseProcessor
|
class: octodns.processor.base.BaseProcessor
|
||||||
|
test:
|
||||||
|
# This helps us get coverage when printing out processor versions
|
||||||
|
class: helpers.TestBaseProcessor
|
||||||
|
|
||||||
zones:
|
zones:
|
||||||
unit.tests.:
|
unit.tests.:
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ from logging import getLogger
|
|||||||
|
|
||||||
from octodns.processor.base import BaseProcessor
|
from octodns.processor.base import BaseProcessor
|
||||||
from octodns.provider.base import BaseProvider
|
from octodns.provider.base import BaseProvider
|
||||||
|
from octodns.provider.yaml import YamlProvider
|
||||||
|
|
||||||
|
|
||||||
class SimpleSource(object):
|
class SimpleSource(object):
|
||||||
@@ -122,3 +123,11 @@ class PlannableProvider(BaseProvider):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.__class__.__name__
|
return self.__class__.__name__
|
||||||
|
|
||||||
|
|
||||||
|
class TestYamlProvider(YamlProvider):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestBaseProcessor(BaseProcessor):
|
||||||
|
pass
|
||||||
|
|||||||
@@ -425,7 +425,7 @@ class TestManager(TestCase):
|
|||||||
plan_output_mock = MagicMock()
|
plan_output_mock = MagicMock()
|
||||||
plan_output_class_mock = MagicMock()
|
plan_output_class_mock = MagicMock()
|
||||||
plan_output_class_mock.return_value = plan_output_mock
|
plan_output_class_mock.return_value = plan_output_mock
|
||||||
mock.return_value = plan_output_class_mock
|
mock.return_value = (plan_output_class_mock, 'ignored', 'ignored')
|
||||||
fh_mock = MagicMock()
|
fh_mock = MagicMock()
|
||||||
|
|
||||||
Manager(get_config_filename('plan-output-filehandle.yaml')
|
Manager(get_config_filename('plan-output-filehandle.yaml')
|
||||||
@@ -441,7 +441,7 @@ class TestManager(TestCase):
|
|||||||
def test_processor_config(self):
|
def test_processor_config(self):
|
||||||
# Smoke test loading a valid config
|
# Smoke test loading a valid config
|
||||||
manager = Manager(get_config_filename('processors.yaml'))
|
manager = Manager(get_config_filename('processors.yaml'))
|
||||||
self.assertEqual(['noop'], list(manager.processors.keys()))
|
self.assertEqual(['noop', 'test'], list(manager.processors.keys()))
|
||||||
# This zone specifies a valid processor
|
# This zone specifies a valid processor
|
||||||
manager.sync(['unit.tests.'])
|
manager.sync(['unit.tests.'])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user