NamespaceConfig

This commit is contained in:
Jakub Warmuz
2015-02-03 11:22:04 +00:00
parent 1d45b466a3
commit 9fb56f31d3
4 changed files with 57 additions and 16 deletions
+35
View File
@@ -0,0 +1,35 @@
"""Let's Encrypt user-supplied configuration."""
import zope.interface
from letsencrypt.client import interfaces
class NamespaceConfig(object):
"""Configuration wrapper around `argparse.Namespace`."""
zope.interface.implements(interfaces.IConfig)
def __init__(self, namespace):
self.namespace = namespace
def __getattr__(self, name):
return getattr(self.namespace, name)
@property
def temp_checkpoint_dir(self):
return os.path.join(
self.namespace.work_dir, constants.TEMP_CHECKPOINT_DIR_NAME)
@property
def in_progress_dir(self):
return os.path.join(
self.namespace.work_dir, constants.IN_PROGRESS_DIR_NAME)
@property
def cert_key_backup(self):
return os.path.join(
self.namespace.work_dir, constants.CERT_KEY_BACKUP_DIR_NAME)
@property
def rev_tokens_dir(self):
return os.path.join(
self.namespace.work_dir, constants.REV_TOKENS_DIR_NAME)
+16
View File
@@ -47,3 +47,19 @@ APACHE_REWRITE_HTTPS_ARGS = [
DVSNI_DOMAIN_SUFFIX = ".acme.invalid"
"""Suffix appended to domains in DVSNI validation."""
TEMP_CHECKPOINT_DIR_NAME = "temp_checkpoint"
"""Temporary checkpoint directory (relative to IConfig.work_dir)."""
IN_PROGRESS_DIR_NAME = "IN_PROGRESS"
"""Directory used before a permanent checkpoint is finalized (relative to
IConfig.work_dir)."""
CERT_KEY_BACKUP_DIR_NAME = "keys-certs"
"""Directory where all certificates and keys are stored (relative to
IConfig.work_dir. Used for easy revocation."""
REV_TOKENS_DIR_NAME = "revocation_tokens"
"""Directory where all revocation tokens are saved (relative to
IConfig.work_dir)."""
+1 -1
View File
@@ -60,7 +60,7 @@ class IChallenge(zope.interface.Interface):
class IConfig(zope.interface.Interface):
"""Marker interface for Let's Encrypt config."""
"""Let's Encrypt uesr-supplied configuration."""
class IInstaller(zope.interface.Interface):
+5 -15
View File
@@ -11,10 +11,11 @@ import sys
import confargparse
import zope.component
import zope.interface
import letsencrypt
from letsencrypt.client import constants
from letsencrypt.client import configuration
from letsencrypt.client import client
from letsencrypt.client import display
from letsencrypt.client import errors
@@ -60,17 +61,6 @@ def create_parser():
help="Working directory.")
add("--backup-dir", default="/var/lib/letsencrypt/backups",
help="Configuration backups directory.")
add("--temp-checkpoint-dir",
default="/var/lib/letsencrypt/temp_checkpoint",
help="Temporary checkpoint directory.")
add("--in-progress-dir",
default="/var/lib/letsencrypt/backups/IN_PROGRESS",
help="Directory used before a permanent checkpoint is finalized")
add("--cert-key-backup", default="/var/lib/letsencrypt/keys-certs",
help="Directory where all certificates and keys are stored. "
"Used for easy revocation.")
add("--rev-tokens-dir", default="/var/lib/letsencrypt/revocation_tokens",
help="Directory where all revocation tokens are saved.")
add("--key-dir", default="/etc/letsencrypt/keys", help="Keys storage.")
add("--cert-dir", default="/etc/letsencrypt/certs",
help="Certificates storage.")
@@ -96,12 +86,12 @@ def create_parser():
return parser
def main(): # pylint: disable=too-many-branches
"""Command line argument parsing and main script execution."""
# note: arg parser internally handles --help (and exits afterwards)
config = create_parser().parse_args()
zope.interface.directlyProvides(config, interfaces.IConfig)
args = create_parser().parse_args()
config = configuration.NamespaceConfig(args)
# note: check is done after arg parsing as --help should work w/o root also.
if not os.geteuid() == 0: