mirror of
https://github.com/certbot/certbot.git
synced 2026-01-21 19:01:07 +03:00
More generality for renewer config. (Still no CLI flags.)
This commit is contained in:
@@ -6,6 +6,7 @@ configuration."""
|
||||
|
||||
# TODO: call new installer API to restart servers after deployment
|
||||
|
||||
import copy
|
||||
import os
|
||||
|
||||
import configobj
|
||||
@@ -87,7 +88,7 @@ def renew(cert, old_version):
|
||||
# (where fewer than all names were renewed)
|
||||
|
||||
|
||||
def main(config=constants.RENEWER_DEFAULTS):
|
||||
def main(config=None):
|
||||
"""main function for autorenewer script."""
|
||||
# TODO: Distinguish automated invocation from manual invocation,
|
||||
# perhaps by looking at sys.argv[0] and inhibiting automated
|
||||
@@ -95,10 +96,17 @@ def main(config=constants.RENEWER_DEFAULTS):
|
||||
# turned it off. (The boolean parameter should probably be
|
||||
# called renewer_enabled.)
|
||||
|
||||
# This attempts to read the renewer config file and augment or replace
|
||||
# Merge supplied config, if provided, on top of builtin defaults
|
||||
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
|
||||
# the renewer defaults with any options contained in that file. If
|
||||
# renewer_config_file is undefined or if the file is nonexistent or
|
||||
# empty, this .merge() will have no effect.
|
||||
# empty, this .merge() will have no effect. TODO: when we have a more
|
||||
# elaborate renewer command line, we will presumably also be able to
|
||||
# specify a config file on the command line, which, if provided, should
|
||||
# take precedence over this one.
|
||||
config.merge(configobj.ConfigObj(config.get("renewer_config_file", "")))
|
||||
|
||||
for i in os.listdir(config["renewal_configs_dir"]):
|
||||
|
||||
@@ -78,13 +78,13 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
||||
and/or systemwide defaults.
|
||||
:type configuration: :class:`configobj.ConfigObj`"""
|
||||
|
||||
def __init__(self, configfile, defaults=constants.RENEWER_DEFAULTS):
|
||||
def __init__(self, configfile, config_opts=None):
|
||||
"""Instantiate a RenewableCert object from an existing lineage.
|
||||
|
||||
:param :class:`configobj.ConfigObj` configfile: an already-parsed
|
||||
ConfigObj object made from reading the renewal config file that
|
||||
defines this lineage.
|
||||
:param :class:`configobj.ConfigObj` defaults: systemwide defaults
|
||||
:param :class:`configobj.ConfigObj` config_opts: systemwide defaults
|
||||
for renewal properties not otherwise specified in the individual
|
||||
renewal config file.
|
||||
|
||||
@@ -109,7 +109,10 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
||||
# TODO: Do we actually use anything from defaults and do we want to
|
||||
# read further defaults from the systemwide renewal configuration
|
||||
# file at this stage?
|
||||
self.configuration = copy.deepcopy(defaults)
|
||||
defaults_copy = copy.deepcopy(constants.RENEWER_DEFAULTS)
|
||||
defaults_copy.merge(config_opts if config_opts is not None
|
||||
else configobj.ConfigObj())
|
||||
self.configuration = defaults_copy
|
||||
self.configuration.merge(self.configfile)
|
||||
|
||||
if not all(x in self.configuration for x in ALL_FOUR):
|
||||
@@ -479,7 +482,7 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
||||
|
||||
@classmethod
|
||||
def new_lineage(cls, lineagename, cert, privkey, chain,
|
||||
renewalparams=None, config=constants.RENEWER_DEFAULTS):
|
||||
renewalparams=None, config=None):
|
||||
# pylint: disable=too-many-locals,too-many-arguments
|
||||
"""Create a new certificate lineage.
|
||||
|
||||
@@ -511,6 +514,10 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
||||
:returns: the newly-created RenewalCert object
|
||||
:rtype: :class:`storage.renewableCert`"""
|
||||
|
||||
defaults_copy = copy.deepcopy(constants.RENEWER_DEFAULTS)
|
||||
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
|
||||
# the renewer defaults with any options contained in that file. If
|
||||
# renewer_config_file is undefined or if the file is nonexistent or
|
||||
|
||||
Reference in New Issue
Block a user