From c83c09e12bd0f73562e6709da2b21f26e88fbb7a Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Fri, 1 Apr 2016 14:07:42 -0700 Subject: [PATCH] Add _WebrootMapAction to webroot.py --- letsencrypt/plugins/webroot.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/letsencrypt/plugins/webroot.py b/letsencrypt/plugins/webroot.py index 2d87d3475..336a58f19 100644 --- a/letsencrypt/plugins/webroot.py +++ b/letsencrypt/plugins/webroot.py @@ -1,5 +1,7 @@ """Webroot plugin.""" +import argparse import errno +import json import logging import os from collections import defaultdict @@ -9,6 +11,7 @@ import six from acme import challenges +from letsencrypt import cli from letsencrypt import errors from letsencrypt import interfaces from letsencrypt.plugins import common @@ -157,6 +160,17 @@ to serve all files under specified web root ({0}).""" raise +class _WebrootMapAction(argparse.Action): + """Action class for parsing webroot_map.""" + + def __call__(self, parser, namespace, webroot_map, option_string=None): + for domains, webroot_path in six.iteritems(json.loads(webroot_map)): + validated_webroot_path = _validate_webroot(webroot_path) + namespace.webroot_map.update( + (d, validated_webroot_path,) + for d in cli.add_domains(namespace, domains)) + + def _match_webroot_with_domains(args_or_config): """Applies the most recent webroot path to all unmatched domains.