Blob Blame History Raw
From 37b6d32f43c2f0f11a87674a8dc1278af09fdec9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <pbrady@redhat.com>
Date: Mon, 11 Feb 2013 17:32:55 +0000
Subject: [PATCH] add /usr/share/$project/*-dist.conf to the default config set

This will lookup /usr/share/$project/$project-dist.conf
and /usr/share/$project/$prog-dist.conf
in the correct precedence order by default.
For example from command line utils which don't specify
the --config-file option.  Note if daemon init scripts
explicitly specify a --config-file then they must specify
all required.

For reference the precedence order is that later --config-file
options will override settings from previous ones.
So when no --config-file option is specified, we insert
the "dist" config file as the first to be parsed,
and settings from there are overridden by any from
/etc/$project/$project.conf and /etc/$prog.conf respectively.

For completeness, note settings in configs from --config-dir
take precedence over any of the --config-file settings above.
---
 oslo_config/cfg.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/oslo_config/cfg.py b/oslo_config/cfg.py
index 77fd44d..902d5a5 100644
--- a/oslo_config/cfg.py
+++ b/oslo_config/cfg.py
@@ -550,6 +550,10 @@ def find_config_files(project=None, prog=None, extension='.conf'):
 
     config_files = []
     if project:
+        config_files.append(_search_dirs(['/usr/share/%s/' % project],
+                                         project, '-dist%s' % extension))
+        config_files.append(_search_dirs(['/usr/share/%s/' % project],
+                                         prog, '-dist%s' % extension))
         config_files.append(_search_dirs(cfg_dirs, project, extension))
     config_files.append(_search_dirs(cfg_dirs, prog, extension))