diff options
author | James Page <james.page@ubuntu.com> | 2017-10-05 10:27:18 +0100 |
---|---|---|
committer | James Page <james.page@ubuntu.com> | 2017-10-06 09:03:53 +0100 |
commit | 36aded18660fc4d515aaabfc7bf1afbfb65e6411 (patch) | |
tree | 6fafa92e5a0f5114fc9b2a470b2d4b8b2585d35c | |
parent | 0cce0be52abddc670f8d7451f240481eaa9fe208 (diff) | |
download | oslo-config-36aded18660fc4d515aaabfc7bf1afbfb65e6411.tar.gz |
Prefer SNAP_COMMON config files4.13.2
User provided configuration files in $SNAP_COMMON should always
be preferred over snap provided default config files in $SNAP.
Re-order the target location list in _get_config_dirs to ensure
that files in $SNAP_COMMON are selected over those in $SNAP.
Change-Id: I7cba87ab328edc05b1e6edd1ff512e8fd5192638
-rw-r--r-- | oslo_config/cfg.py | 8 | ||||
-rw-r--r-- | oslo_config/tests/test_cfg.py | 6 |
2 files changed, 8 insertions, 6 deletions
diff --git a/oslo_config/cfg.py b/oslo_config/cfg.py index cbdcdfa..662afa6 100644 --- a/oslo_config/cfg.py +++ b/oslo_config/cfg.py @@ -656,8 +656,8 @@ def _get_config_dirs(project=None): If a project is specified and installed from a snap package, following directories are also returned: - ${SNAP}/etc/${project} ${SNAP_COMMON}/etc/${project} + ${SNAP}/etc/${project} Otherwise, if project is not specified, these directories are returned: @@ -672,8 +672,8 @@ def _get_config_dirs(project=None): _fixpath('~'), os.path.join('/etc', project) if project else None, '/etc', - os.path.join(snap, "etc", project) if snap and project else None, os.path.join(snap_c, "etc", project) if snap_c and project else None, + os.path.join(snap, "etc", project) if snap and project else None, ] return [x for x in cfg_dirs if x] @@ -724,8 +724,8 @@ def find_config_files(project=None, prog=None, extension='.conf'): ~/ /etc/${project}/ /etc/ - ${SNAP}/etc/${project} ${SNAP_COMMON}/etc/${project} + ${SNAP}/etc/${project} We return an absolute path for (at most) one of each the default config files, for the topmost directory it exists in. @@ -756,8 +756,8 @@ def find_config_dirs(project=None, prog=None, extension='.conf.d'): ~/ /etc/${project}/ /etc/ - ${SNAP}/etc/${project} ${SNAP_COMMON}/etc/${project} + ${SNAP}/etc/${project} We return an absolute path for each of the two config dirs, in the first place we find it (iff we find it). diff --git a/oslo_config/tests/test_cfg.py b/oslo_config/tests/test_cfg.py index 67d9c43..4e7f58c 100644 --- a/oslo_config/tests/test_cfg.py +++ b/oslo_config/tests/test_cfg.py @@ -224,7 +224,8 @@ class FindConfigFilesTestCase(BaseTestCase): self.assertEqual(cfg.find_config_files(project='blaa'), config_files) def test_find_config_files_snap(self): - config_files = ['/snap/nova/current/etc/blaa/blaa.conf'] + config_files = ['/snap/nova/current/etc/blaa/blaa.conf', + '/var/snap/nova/common/etc/blaa/blaa.conf'] fake_env = {'SNAP': '/snap/nova/current/', 'SNAP_COMMON': '/var/snap/nova/common/'} @@ -233,7 +234,8 @@ class FindConfigFilesTestCase(BaseTestCase): lambda p: p in config_files)) self.useFixture(fixtures.MonkeyPatch('os.environ', fake_env)) - self.assertEqual(cfg.find_config_files(project='blaa'), config_files) + self.assertEqual(cfg.find_config_files(project='blaa'), + ['/var/snap/nova/common/etc/blaa/blaa.conf']) def test_find_config_files_with_extension(self): config_files = ['/etc/foo.json'] |