mirror of
https://github.com/certbot/certbot.git
synced 2026-06-05 06:42:10 -04:00
* Implement certbot services * Various fixes * Local oldest requirements * Clean imports * Add unit tests for certbot.services * Clean code * Protect against nullity of global services * Fix CLI * Fix tests * Consistent test behavior * Various fixes * Clean code * Remove reporter service, migrate display service in certbot.display.util. * Fix test * Fix apache compatibility test * Fix oldest test * Setup certbot.display.service module * Reintegrate in util * Fix imports * Fix tests and documentation * Refactor * Cleanup * Cleanup * Clean imports * Add unit tests * Borrow sphinx build fix from #8863 * Fix type * Add comment * Do not reuse existing display service, which never exist at that time * Make get_display() private * Fix lint * Make display internal * Fix circular dependencies * Fixing circular dependencies * Rename patch methods and update docstring * Update deprecation messages * Update certbot/certbot/_internal/display/obj.py Co-authored-by: Brad Warren <bmw@users.noreply.github.com> * Update certbot/certbot/tests/util.py Co-authored-by: Brad Warren <bmw@users.noreply.github.com> * Update certbot/certbot/tests/util.py Co-authored-by: Brad Warren <bmw@users.noreply.github.com> * Update certbot/certbot/tests/util.py Co-authored-by: Brad Warren <bmw@users.noreply.github.com> * Update certbot/certbot/tests/util.py Co-authored-by: Brad Warren <bmw@users.noreply.github.com> * Add links * Avoid relying on internal certbot packages from certbot-apache * Keep same behavior for patch_get_utility* * Better diff * Add changelog * Update certbot/certbot/tests/util.py Co-authored-by: Brad Warren <bmw@users.noreply.github.com> Co-authored-by: Brad Warren <bmw@users.noreply.github.com>
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
"""Contains UI methods for Nginx operations."""
|
|
import logging
|
|
|
|
from certbot.display import util as display_util
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def select_vhost_multiple(vhosts):
|
|
"""Select multiple Vhosts to install the certificate for
|
|
:param vhosts: Available Nginx VirtualHosts
|
|
:type vhosts: :class:`list` of type `~obj.Vhost`
|
|
:returns: List of VirtualHosts
|
|
:rtype: :class:`list`of type `~obj.Vhost`
|
|
"""
|
|
if not vhosts:
|
|
return []
|
|
tags_list = [vhost.display_repr()+"\n" for vhost in vhosts]
|
|
# Remove the extra newline from the last entry
|
|
if tags_list:
|
|
tags_list[-1] = tags_list[-1][:-1]
|
|
code, names = display_util.checklist(
|
|
"Which server blocks would you like to modify?",
|
|
tags=tags_list, force_interactive=True)
|
|
if code == display_util.OK:
|
|
return_vhosts = _reversemap_vhosts(names, vhosts)
|
|
return return_vhosts
|
|
return []
|
|
|
|
|
|
def _reversemap_vhosts(names, vhosts):
|
|
"""Helper function for select_vhost_multiple for mapping string
|
|
representations back to actual vhost objects"""
|
|
return_vhosts = []
|
|
|
|
for selection in names:
|
|
for vhost in vhosts:
|
|
if vhost.display_repr().strip() == selection.strip():
|
|
return_vhosts.append(vhost)
|
|
return return_vhosts
|