From 4f0d0936af099321f581262c1b956fd10db76df5 Mon Sep 17 00:00:00 2001 From: Jakub Warmuz Date: Wed, 22 Apr 2015 08:44:51 +0000 Subject: [PATCH] IPluginFactory --- letsencrypt/client/interfaces.py | 20 +++++++++++++++++++ .../client/plugins/apache/configurator.py | 1 + .../plugins/standalone/authenticator.py | 5 +++++ 3 files changed, 26 insertions(+) diff --git a/letsencrypt/client/interfaces.py b/letsencrypt/client/interfaces.py index 80a43f885..3ce0e990a 100644 --- a/letsencrypt/client/interfaces.py +++ b/letsencrypt/client/interfaces.py @@ -5,6 +5,26 @@ import zope.interface # pylint: disable=too-few-public-methods +class IPluginFactory(zope.interface.Interface): + + def __call__(config): + """Create new `IPlugin`. + + :param IConfig config: Configuration. + + """ + + def add_parser_arguments(add): + """Add plugin arguments to the CLI argument parser. + + :param callable add: Function that proxies calls to + `argparse.ArgumentParser.add_argument` prepending options + with unique plugin name prefix. + + """ + # TODO: move to IPlugin? + + class IPlugin(zope.interface.Interface): """Let's Encrypt plugin.""" diff --git a/letsencrypt/client/plugins/apache/configurator.py b/letsencrypt/client/plugins/apache/configurator.py index 55f7e2875..34a57b2b0 100644 --- a/letsencrypt/client/plugins/apache/configurator.py +++ b/letsencrypt/client/plugins/apache/configurator.py @@ -79,6 +79,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): """ zope.interface.implements(interfaces.IAuthenticator, interfaces.IInstaller) + zope.interface.classProvides(interfaces.IPluginFactory) description = "Apache Web Server" diff --git a/letsencrypt/client/plugins/standalone/authenticator.py b/letsencrypt/client/plugins/standalone/authenticator.py index e0b06aa30..fa4e62d7f 100644 --- a/letsencrypt/client/plugins/standalone/authenticator.py +++ b/letsencrypt/client/plugins/standalone/authenticator.py @@ -30,9 +30,14 @@ class StandaloneAuthenticator(object): """ zope.interface.implements(interfaces.IAuthenticator) + zope.interface.classProvides(interfaces.IPluginFactory) description = "Standalone Authenticator" + @classmethod + def add_parser_arguments(cls, add): + pass + def __init__(self, unused_config): self.child_pid = None self.parent_pid = os.getpid()