mirror of
https://github.com/certbot/certbot.git
synced 2026-06-09 08:42:57 -04:00
Move --webroot-path processing into cli.py
Since it is now interdependent with --domains (This is much more elegant than trying to APIify the interaction)
This commit is contained in:
parent
19f348b416
commit
e1f0fcca8f
2 changed files with 28 additions and 17 deletions
|
|
@ -1022,6 +1022,12 @@ def _plugins_parsing(helpful, plugins):
|
|||
help='Provide laborious manual instructions for obtaining a cert')
|
||||
helpful.add("plugins", "--webroot", action="store_true",
|
||||
help='Obtain certs by placing files in a webroot directory.')
|
||||
|
||||
# This would normally be a flag within the webroot plugin, the webroot
|
||||
# plugin, but because it is parsed in conjunction with --domains, it lives
|
||||
# here
|
||||
helpful.add("webroot", "-w", "--webroot-path", action=WebrootPathProcessor,
|
||||
help="public_html / webroot path")
|
||||
#helpful.add("plugins", "-w", action=WebrootAction,
|
||||
# help='Obtain certs by placing files in a webroot directory.')
|
||||
|
||||
|
|
@ -1031,6 +1037,25 @@ def _plugins_parsing(helpful, plugins):
|
|||
|
||||
helpful.add_plugin_args(plugins)
|
||||
|
||||
|
||||
class WebrootPathProcessor(argparse.Action):
|
||||
def __call__(self, parser, config, webroot, option_string=None):
|
||||
"""
|
||||
Keep a record of --webroot-path / -w flags during processing, so that
|
||||
we know which apply to which -d flags
|
||||
"""
|
||||
if not config.webroot_path:
|
||||
config.webroot_path = []
|
||||
# if any --domain flags preceded the first --webroot-path flag,
|
||||
# apply that webroot path to those; subsequent entries in
|
||||
# config.webroot_map are filled in by cli.DomainFlagProcessor
|
||||
if config.domains:
|
||||
config.webroot_map = dict([(d, webroot) for d in config.domains])
|
||||
else:
|
||||
config.webroot_map = {}
|
||||
config.webroot_path.append(webroot)
|
||||
|
||||
|
||||
class DomainFlagProcessor(argparse.Action):
|
||||
def __call__(self, parser, config, domain_arg, option_string=None):
|
||||
"""
|
||||
|
|
@ -1047,6 +1072,7 @@ class DomainFlagProcessor(argparse.Action):
|
|||
for d in new_domains:
|
||||
config.webroot_map[d] = config.webroot_path[-1]
|
||||
|
||||
|
||||
def setup_log_file_handler(args, logfile, fmt):
|
||||
"""Setup file debug logging."""
|
||||
log_file_path = os.path.join(args.logs_dir, logfile)
|
||||
|
|
|
|||
|
|
@ -54,22 +54,7 @@ from letsencrypt.plugins import common
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class WebrootPathProcessor(argparse.Action):
|
||||
def __call__(self, parser, config, webroot, option_string=None):
|
||||
"""
|
||||
Keep a record of --webroot-path / -w flags during processing, so that
|
||||
we know which apply to which -d flags
|
||||
"""
|
||||
if not config.webroot_path:
|
||||
config.webroot_path = []
|
||||
# if any --domain flags preceded the first --webroot-path flag,
|
||||
# apply that webroot path to those; subsequent entries in
|
||||
# config.webroot_map are filled in by cli.DomainFlagProcessor
|
||||
if config.domains:
|
||||
config.webroot_map = dict([(d, webroot) for d in config.domains])
|
||||
else:
|
||||
config.webroot_map = {}
|
||||
config.webroot_path.append(webroot)
|
||||
|
||||
|
||||
class Authenticator(common.Plugin):
|
||||
"""Webroot Authenticator."""
|
||||
|
|
@ -89,7 +74,7 @@ to serve all files under specified web root ({0})."""
|
|||
|
||||
@classmethod
|
||||
def add_parser_arguments(cls, add):
|
||||
add("path", "-w", help="public_html / webroot path", action=WebrootPathAccumulator)
|
||||
pass
|
||||
|
||||
def get_chall_pref(self, domain): # pragma: no cover
|
||||
# pylint: disable=missing-docstring,no-self-use,unused-argument
|
||||
|
|
|
|||
Loading…
Reference in a new issue