|
|
10d6a06 |
From 9e78caadf9a668f799de1274a729d0b157a83330 Mon Sep 17 00:00:00 2001
|
|
|
10d6a06 |
From: Javier Pena <jpena@redhat.com>
|
|
|
10d6a06 |
Date: Fri, 2 Dec 2016 17:02:46 +0100
|
|
Alan Pevec |
af6f3ae |
Subject: [PATCH] add /usr/share/$project/*-dist.conf to the default config set
|
|
|
c573f8e |
|
|
|
c573f8e |
This will lookup /usr/share/$project/$project-dist.conf
|
|
Alan Pevec |
af6f3ae |
and /usr/share/$project/$prog-dist.conf
|
|
|
c573f8e |
in the correct precedence order by default.
|
|
|
c573f8e |
For example from command line utils which don't specify
|
|
|
c573f8e |
the --config-file option. Note if daemon init scripts
|
|
|
c573f8e |
explicitly specify a --config-file then they must specify
|
|
|
c573f8e |
all required.
|
|
|
c573f8e |
|
|
|
c573f8e |
For reference the precedence order is that later --config-file
|
|
|
c573f8e |
options will override settings from previous ones.
|
|
|
c573f8e |
So when no --config-file option is specified, we insert
|
|
|
c573f8e |
the "dist" config file as the first to be parsed,
|
|
|
c573f8e |
and settings from there are overridden by any from
|
|
|
c573f8e |
/etc/$project/$project.conf and /etc/$prog.conf respectively.
|
|
|
c573f8e |
|
|
|
c573f8e |
For completeness, note settings in configs from --config-dir
|
|
|
c573f8e |
take precedence over any of the --config-file settings above.
|
|
|
c573f8e |
---
|
|
|
10d6a06 |
oslo_config/cfg.py | 8 ++++++--
|
|
|
10d6a06 |
1 file changed, 6 insertions(+), 2 deletions(-)
|
|
|
c573f8e |
|
|
Alan Pevec |
37b5ef1 |
diff --git a/oslo_config/cfg.py b/oslo_config/cfg.py
|
|
|
10d6a06 |
index b7b10bf..564341a 100644
|
|
Alan Pevec |
37b5ef1 |
--- a/oslo_config/cfg.py
|
|
Alan Pevec |
37b5ef1 |
+++ b/oslo_config/cfg.py
|
|
|
10d6a06 |
@@ -651,8 +651,12 @@ def _find_config_files(project, prog, extension):
|
|
|
10d6a06 |
prog = prog[:-3]
|
|
|
c573f8e |
|
|
|
10d6a06 |
cfg_dirs = _get_config_dirs(project)
|
|
|
10d6a06 |
- config_files = (_search_dirs(cfg_dirs, p, extension)
|
|
|
10d6a06 |
- for p in [project, prog] if p)
|
|
|
10d6a06 |
+ config_files = [_search_dirs(['/usr/share/%s/' % project], p,
|
|
|
10d6a06 |
+ '-dist%s' % extension)
|
|
|
10d6a06 |
+ for p in [project, prog] if p]
|
|
|
10d6a06 |
+ config_files_default = (_search_dirs(cfg_dirs, p, extension)
|
|
|
10d6a06 |
+ for p in [project, prog] if p)
|
|
|
10d6a06 |
+ config_files.extend([x for x in config_files_default if x])
|
|
|
c573f8e |
|
|
|
10d6a06 |
return [x for x in config_files if x]
|
|
|
10d6a06 |
|
|
|
10d6a06 |
--
|
|
|
10d6a06 |
2.7.4
|
|
|
10d6a06 |
|