Prefer SNAP_COMMON config files
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
This commit is contained in:
parent
0cce0be52a
commit
36aded1866
|
@ -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).
|
||||
|
|
|
@ -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']
|
||||
|
|
Loading…
Reference in New Issue