Skip to content

Commit

Permalink
Hide null installer (fixes certbot#789).
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba committed Sep 28, 2015
1 parent 928fa7b commit 315b357
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion letsencrypt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def plugins_cmd(args, config, plugins): # TODO: Use IDisplay rather than print
logger.debug("Expected interfaces: %s", args.ifaces)

ifaces = [] if args.ifaces is None else args.ifaces
filtered = plugins.ifaces(ifaces)
filtered = plugins.visible().ifaces(ifaces)
logger.debug("Filtered plugins: %r", filtered)

if not args.init and not args.prepare:
Expand Down
2 changes: 1 addition & 1 deletion letsencrypt/display/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def pick_plugin(config, default, plugins, question, ifaces):
# throw more UX-friendly error if default not in plugins
filtered = plugins.filter(lambda p_ep: p_ep.name == default)
else:
filtered = plugins.ifaces(ifaces)
filtered = plugins.visible().ifaces(ifaces)

filtered.init(config)
verified = filtered.verify(ifaces)
Expand Down
9 changes: 9 additions & 0 deletions letsencrypt/plugins/disco.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def description_with_name(self):
"""Description with name. Handy for UI."""
return "{0} ({1})".format(self.description, self.name)

@property
def hidden(self):
"""Should this plugin be hidden from UI?"""
return getattr(self.plugin_cls, "hidden", False)

def ifaces(self, *ifaces_groups):
"""Does plugin implements specified interface groups?"""
return not ifaces_groups or any(
Expand Down Expand Up @@ -183,6 +188,10 @@ def filter(self, pred):
return type(self)(dict((name, plugin_ep) for name, plugin_ep
in self._plugins.iteritems() if pred(plugin_ep)))

def visible(self):
"""Filter plugins based on visibility."""
return self.filter(lambda plugin_ep: not plugin_ep.hidden)

def ifaces(self, *ifaces_groups):
"""Filter plugins based on interfaces."""
# pylint: disable=star-args
Expand Down
1 change: 1 addition & 0 deletions letsencrypt/plugins/null.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Installer(common.Plugin):
zope.interface.classProvides(interfaces.IPluginFactory)

description = "Null Installer"
hidden = True

# pylint: disable=missing-docstring,no-self-use

Expand Down
12 changes: 7 additions & 5 deletions letsencrypt/tests/display/ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_default_provided(self):

def test_no_default(self):
self._call()
self.assertEqual(1, self.reg.ifaces.call_count)
self.assertEqual(1, self.reg.visible().ifaces.call_count)

def test_no_candidate(self):
self.assertTrue(self._call() is None)
Expand All @@ -94,21 +94,23 @@ def test_single(self):
plugin_ep.init.return_value = "foo"
plugin_ep.misconfigured = False

self.reg.ifaces().verify().available.return_value = {"bar": plugin_ep}
self.reg.visible().ifaces().verify().available.return_value = {
"bar": plugin_ep}
self.assertEqual("foo", self._call())

def test_single_misconfigured(self):
plugin_ep = mock.MagicMock()
plugin_ep.init.return_value = "foo"
plugin_ep.misconfigured = True

self.reg.ifaces().verify().available.return_value = {"bar": plugin_ep}
self.reg.visible().ifaces().verify().available.return_value = {
"bar": plugin_ep}
self.assertTrue(self._call() is None)

def test_multiple(self):
plugin_ep = mock.MagicMock()
plugin_ep.init.return_value = "foo"
self.reg.ifaces().verify().available.return_value = {
self.reg.visible().ifaces().verify().available.return_value = {
"bar": plugin_ep,
"baz": plugin_ep,
}
Expand All @@ -119,7 +121,7 @@ def test_multiple(self):
[plugin_ep, plugin_ep], self.question)

def test_choose_plugin_none(self):
self.reg.ifaces().verify().available.return_value = {
self.reg.visible().ifaces().verify().available.return_value = {
"bar": None,
"baz": None,
}
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def read_file(filename, encoding='utf8'):
],
'letsencrypt.plugins': [
'manual = letsencrypt.plugins.manual:Authenticator',
# TODO: null should probably not be presented to the user
'null = letsencrypt.plugins.null:Installer',
'standalone = letsencrypt.plugins.standalone.authenticator'
':StandaloneAuthenticator',
Expand Down

0 comments on commit 315b357

Please sign in to comment.