From adcdecb1177c83e0ba0c673ab876aa763d11ca7b Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Fri, 24 Jun 2016 15:08:13 +1000 Subject: [PATCH] Pop oslo_config_config before doing paste convert This doesn't make a huge difference but if we don't pop the local oslo conf options from the conf dict then they remain around in the paste overrides dict. Rearrange them to pop rather than testing there presence. Change-Id: I9482831d6d415da0a2e38fd3c39f58ba96740842 --- keystonemiddleware/_common/config.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/keystonemiddleware/_common/config.py b/keystonemiddleware/_common/config.py index aaa23ff9..883d3776 100644 --- a/keystonemiddleware/_common/config.py +++ b/keystonemiddleware/_common/config.py @@ -67,6 +67,10 @@ def _conf_values_type_convert(group_name, all_options, conf): class Config(object): def __init__(self, name, group_name, all_options, conf): + local_oslo_config = conf.pop('oslo_config_config', None) + local_config_project = conf.pop('oslo_config_project', None) + local_config_file = conf.pop('oslo_config_file', None) + # NOTE(wanghong): If options are set in paste file, all the option # values passed into conf are string type. So, we should convert the # conf value into correct type. @@ -81,21 +85,14 @@ class Config(object): # AuthProtocol can pass in an existing oslo.config as the # value of the "oslo_config_config" key in conf. If both are # set "olso_config_config" is used. - local_oslo_config = None + if local_config_project and not local_oslo_config: + config_files = [local_config_file] if local_config_file else None - try: - local_oslo_config = conf['oslo_config_config'] - except KeyError: - if 'oslo_config_project' in conf: - if 'oslo_config_file' in conf: - config_files = [conf['oslo_config_file']] - else: - config_files = None - local_oslo_config = cfg.ConfigOpts() - local_oslo_config([], - project=conf['oslo_config_project'], - default_config_files=config_files, - validate_default_values=True) + local_oslo_config = cfg.ConfigOpts() + local_oslo_config([], + project=local_config_project, + default_config_files=config_files, + validate_default_values=True) if local_oslo_config: for group, opts in all_options: