mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 03:41:53 +02:00
storage.config_with_defaults
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
"""Let's Encrypt constants."""
|
"""Let's Encrypt constants."""
|
||||||
import configobj
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from acme import challenges
|
from acme import challenges
|
||||||
@@ -27,7 +26,7 @@ CLI_DEFAULTS = dict(
|
|||||||
"""Defaults for CLI flags and `.IConfig` attributes."""
|
"""Defaults for CLI flags and `.IConfig` attributes."""
|
||||||
|
|
||||||
|
|
||||||
RENEWER_DEFAULTS = configobj.ConfigObj(dict(
|
RENEWER_DEFAULTS = dict(
|
||||||
renewer_config_file="/etc/letsencrypt/renewer.conf",
|
renewer_config_file="/etc/letsencrypt/renewer.conf",
|
||||||
renewal_configs_dir="/etc/letsencrypt/configs",
|
renewal_configs_dir="/etc/letsencrypt/configs",
|
||||||
archive_dir="/etc/letsencrypt/archive",
|
archive_dir="/etc/letsencrypt/archive",
|
||||||
@@ -35,7 +34,7 @@ RENEWER_DEFAULTS = configobj.ConfigObj(dict(
|
|||||||
renewer_enabled="yes",
|
renewer_enabled="yes",
|
||||||
renew_before_expiry="30 days",
|
renew_before_expiry="30 days",
|
||||||
deploy_before_expiry="20 days",
|
deploy_before_expiry="20 days",
|
||||||
))
|
)
|
||||||
"""Defaults for renewer script."""
|
"""Defaults for renewer script."""
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,11 @@ within lineages of successor certificates, according to configuration.
|
|||||||
.. todo:: Call new installer API to restart servers after deployment
|
.. todo:: Call new installer API to restart servers after deployment
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import copy
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import configobj
|
import configobj
|
||||||
|
|
||||||
from letsencrypt import configuration
|
from letsencrypt import configuration
|
||||||
from letsencrypt import constants
|
|
||||||
from letsencrypt import client
|
from letsencrypt import client
|
||||||
from letsencrypt import crypto_util
|
from letsencrypt import crypto_util
|
||||||
from letsencrypt import notify
|
from letsencrypt import notify
|
||||||
@@ -102,10 +100,7 @@ def main(config=None):
|
|||||||
# turned it off. (The boolean parameter should probably be
|
# turned it off. (The boolean parameter should probably be
|
||||||
# called renewer_enabled.)
|
# called renewer_enabled.)
|
||||||
|
|
||||||
# Merge supplied config, if provided, on top of builtin defaults
|
config = storage.config_with_defaults(config)
|
||||||
defaults_copy = copy.deepcopy(constants.RENEWER_DEFAULTS)
|
|
||||||
defaults_copy.merge(config if config is not None else configobj.ConfigObj())
|
|
||||||
config = defaults_copy
|
|
||||||
# Now attempt to read the renewer config file and augment or replace
|
# Now attempt to read the renewer config file and augment or replace
|
||||||
# the renewer defaults with any options contained in that file. If
|
# the renewer defaults with any options contained in that file. If
|
||||||
# renewer_config_file is undefined or if the file is nonexistent or
|
# renewer_config_file is undefined or if the file is nonexistent or
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
"""Renewable certificates storage."""
|
"""Renewable certificates storage."""
|
||||||
import copy
|
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@@ -17,6 +16,13 @@ from letsencrypt import le_util
|
|||||||
ALL_FOUR = ("cert", "privkey", "chain", "fullchain")
|
ALL_FOUR = ("cert", "privkey", "chain", "fullchain")
|
||||||
|
|
||||||
|
|
||||||
|
def config_with_defaults(config=None):
|
||||||
|
"""Merge supplied config, if provided, on top of builtin defaults."""
|
||||||
|
defaults_copy = configobj.ConfigObj(constants.RENEWER_DEFAULTS)
|
||||||
|
defaults_copy.merge(config if config is not None else configobj.ConfigObj())
|
||||||
|
return defaults_copy
|
||||||
|
|
||||||
|
|
||||||
def parse_time_interval(interval, textparser=parsedatetime.Calendar()):
|
def parse_time_interval(interval, textparser=parsedatetime.Calendar()):
|
||||||
"""Parse the time specified time interval.
|
"""Parse the time specified time interval.
|
||||||
|
|
||||||
@@ -103,10 +109,7 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
|||||||
# TODO: Do we actually use anything from defaults and do we want to
|
# TODO: Do we actually use anything from defaults and do we want to
|
||||||
# read further defaults from the systemwide renewal configuration
|
# read further defaults from the systemwide renewal configuration
|
||||||
# file at this stage?
|
# file at this stage?
|
||||||
defaults_copy = copy.deepcopy(constants.RENEWER_DEFAULTS)
|
self.configuration = config_with_defaults(config_opts)
|
||||||
defaults_copy.merge(config_opts if config_opts is not None
|
|
||||||
else configobj.ConfigObj())
|
|
||||||
self.configuration = defaults_copy
|
|
||||||
self.configuration.merge(self.configfile)
|
self.configuration.merge(self.configfile)
|
||||||
|
|
||||||
if not all(x in self.configuration for x in ALL_FOUR):
|
if not all(x in self.configuration for x in ALL_FOUR):
|
||||||
@@ -528,10 +531,7 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
|||||||
:returns: the newly-created RenewalCert object
|
:returns: the newly-created RenewalCert object
|
||||||
:rtype: :class:`storage.renewableCert`"""
|
:rtype: :class:`storage.renewableCert`"""
|
||||||
|
|
||||||
defaults_copy = copy.deepcopy(constants.RENEWER_DEFAULTS)
|
config = config_with_defaults(config)
|
||||||
defaults_copy.merge(config if config is not None
|
|
||||||
else configobj.ConfigObj())
|
|
||||||
config = defaults_copy
|
|
||||||
# This attempts to read the renewer config file and augment or replace
|
# This attempts to read the renewer config file and augment or replace
|
||||||
# the renewer defaults with any options contained in that file. If
|
# the renewer defaults with any options contained in that file. If
|
||||||
# renewer_config_file is undefined or if the file is nonexistent or
|
# renewer_config_file is undefined or if the file is nonexistent or
|
||||||
|
|||||||
Reference in New Issue
Block a user