Merge "Specify the config file with environment variable"
This commit is contained in:
commit
27dff22c6b
|
@ -43,6 +43,10 @@ locations:
|
|||
|
||||
The first file found wins.
|
||||
|
||||
You can also set the environment variable `OS_CLIENT_CONFIG_FILE` to an
|
||||
absolute path of a file to look for and that location will be inserted at the
|
||||
front of the file search list.
|
||||
|
||||
The keys are all of the keys you'd expect from `OS_*` - except lower case
|
||||
and without the OS prefix. So, region name is set with `region_name`.
|
||||
|
||||
|
|
|
@ -106,6 +106,10 @@ class OpenStackConfig(object):
|
|||
self._config_files = config_files or CONFIG_FILES
|
||||
self._vendor_files = vendor_files or VENDOR_FILES
|
||||
|
||||
config_file_override = os.environ.pop('OS_CLIENT_CONFIG_FILE', None)
|
||||
if config_file_override:
|
||||
self._config_files.insert(0, config_file_override)
|
||||
|
||||
self.defaults = defaults.get_defaults()
|
||||
if override_defaults:
|
||||
self.defaults.update(override_defaults)
|
||||
|
|
|
@ -84,3 +84,12 @@ class TestEnviron(base.TestCase):
|
|||
self._assert_cloud_details(cc)
|
||||
cc = c.get_one_cloud('_test_cloud_no_vendor')
|
||||
self._assert_cloud_details(cc)
|
||||
|
||||
def test_config_file_override(self):
|
||||
self.useFixture(
|
||||
fixtures.EnvironmentVariable(
|
||||
'OS_CLIENT_CONFIG_FILE', self.cloud_yaml))
|
||||
c = config.OpenStackConfig(config_files=[],
|
||||
vendor_files=[self.vendor_yaml])
|
||||
cc = c.get_one_cloud('_test-cloud_')
|
||||
self._assert_cloud_details(cc)
|
||||
|
|
Loading…
Reference in New Issue