Skip to content
This repository has been archived by the owner on Apr 5, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release-0.0.1.dev5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Stone committed Aug 9, 2018
2 parents 513a9a6 + 3f2ac6b commit ede2262
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 530 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
=========

0.0.1.dev5 (2018-08-09)
-----------------------

Changes
~~~~~~~

Import plugins_loader from Gordon to obtain metrics client

0.0.1.dev3 (2018-03-22)
-----------------------

Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include *.txt LICENSE tox.ini .coveragerc *.rst *.toml.example OWNERS
recursive-include gordon_janitor *.py
recursive-include tests *.py
recursive-include tests *.py *.toml

# Exclude service-specific config
exclude gordon-janitor*.toml
Expand Down
4 changes: 2 additions & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ main
plugins_loader
--------------

.. automodule:: gordon_janitor.plugins_loader
.. automodule:: gordon.plugins_loader

.. autofunction:: gordon_janitor.plugins_loader.load_plugins
.. autofunction:: gordon.plugins_loader.load_plugins
2 changes: 1 addition & 1 deletion docs/plugins.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gordon Janitor's Plugin System
==============================

.. automodule:: gordon_janitor.plugins_loader
.. automodule:: gordon.plugins_loader
:noindex:

Writing a Plugin
Expand Down
2 changes: 1 addition & 1 deletion gordon_janitor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

__author__ = 'Lynn Root'
__version__ = '0.0.1.dev4'
__version__ = '0.0.1.dev5'
__license__ = 'Apache 2.0'
__email__ = 'lynn@spotify.com'
__description__ = 'DNS record reconciliation for Gordon: Event-driven Cloud DNS'
Expand Down
10 changes: 7 additions & 3 deletions gordon_janitor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@
import click
import toml
import ulogger
from gordon import plugins_loader

from gordon_janitor import __version__ as version
from gordon_janitor import exceptions
from gordon_janitor import interfaces
from gordon_janitor import plugins_loader


plugins_loader.PLUGIN_NAMESPACE = 'gordon_janitor.plugins'


def _load_config(root=''):
Expand Down Expand Up @@ -161,8 +164,9 @@ def run(config_root):
'changes_channel': asyncio.Queue(),
}

plugin_names, plugins, errors = plugins_loader.load_plugins(config,
plugin_kwargs)
plugin_names, plugins, errors, plugin_kwargs = plugins_loader.load_plugins(
config, plugin_kwargs)

if errors:
base_msg = 'Plugin was not loaded:'
_log_or_exit_on_exceptions(base_msg, errors, debug_mode)
Expand Down
210 changes: 0 additions & 210 deletions gordon_janitor/plugins_loader.py

This file was deleted.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
click==6.7
gordon-dns==0.0.1.dev7
setuptools==38.2.5
toml==0.9.3.1
ulogger==1.0.1
Expand Down
48 changes: 19 additions & 29 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
Module for reusable pytest fixtures.
"""

import os

import pkg_resources
import pytest

Expand All @@ -42,60 +44,48 @@ class FakePluginException(Exception):

@pytest.fixture(scope='session')
def config_file():
plugins = '["authority.plugin", "reconciler.plugin", "publisher.plugin"]'
return ('[core]\n'
f'plugins = {plugins}\n'
'debug = true\n'
'[core.logging]\n'
'level = "debug"\n'
'handlers = ["stream"]\n'
'[authority]\n'
'a_key = "a_value"\n'
'b_key = "b_value"\n'
'[authority.plugin]\n'
'a_key = "another_value"\n'
'[reconciler.plugin]\n'
'd_key = "d_value"\n'
'[publisher.plugin]\n'
'e_key = "e_value"')
here = os.path.dirname(os.path.realpath(__file__))
filepath = os.path.join(here, 'fixtures/test-gordon-janitor.toml')
with open(filepath, 'r') as f:
return f.read()


@pytest.fixture
def loaded_config():
return {
'core': {
'plugins': [
'authority.plugin', 'reconciler.plugin', 'publisher.plugin'],
'xyz.authority',
'xyz.reconciler',
'xyz.publisher'],
'debug': True,
'logging': {
'level': 'debug',
'handlers': ['stream'],
'format': '%(created)f %(levelno)d %(message)s',
'date_format': '%Y-%m-%dT%H:%M:%S',
}
},
'authority': {
'xyz': {
'a_key': 'a_value',
'b_key': 'b_value',
'plugin': {
'authority': {
'a_key': 'another_value',
},
},
'reconciler': {
'plugin': {
'reconciler': {
'd_key': 'd_value',
},
},
'publisher': {
'plugin': {
'e_key': 'e_value',
},
},
'publisher': {
'c_key': 'c_value',
}
}
}


@pytest.fixture
def plugins(mocker):
plugins = {}
names = ['authority.plugin', 'reconciler.plugin', 'publisher.plugin']
names = ['xyz.authority', 'xyz.reconciler', 'xyz.publisher']
for name in names:
plugin_mock = mocker.MagicMock(pkg_resources.EntryPoint, autospec=True)
plugin_mock.name = name
Expand Down

0 comments on commit ede2262

Please sign in to comment.