summaryrefslogtreecommitdiff
path: root/doc/source
diff options
context:
space:
mode:
authorChris Dent <cdent@anticdent.org>2018-07-25 20:01:37 +0100
committerChris Dent <cdent@anticdent.org>2018-10-17 20:49:05 +0100
commitea8a0f6a8b260474151fb27c2adc9dcc88774850 (patch)
tree0f887fdeadfb202066a8e3c2d763e1efda6ec664 /doc/source
parentb12783ea0f86dbe030094634f1e25303a6472f3c (diff)
downloadoslo-config-ea8a0f6a8b260474151fb27c2adc9dcc88774850.tar.gz
Add support for looking in environment for config
An _environment source is added that looks in os.environ for values. Using the environment is on by default, but can be shut down by setting `use_env` to False when __call__ is called. The enviroment is inspected before any other sources of config data but the value is used after command line arguments and before config file options. This is done by checking both the command line and config files and then inspecting the location of the result. If it is command_line, we use it. If not, we use the environment value (if any). If there's no environment value, the config file value is used. If checking the command line and config file results in a KeyError, the environment value is used, if set. The names of the environment variables follow the rules described in oslo_config.sources._environment. A new exception has been added: ConfigSourceValueError, this is the superclass of the existing ConfigFileValueError. The code in _do_get has been updated to only use ConfigFileValueError when it is in fact a file from whence a ValueError came. Documentation has been updated and a rlease note created to indicate the new functionality. Change-Id: I3245c40ebdcc96f8e3b2dc0bab3b4aa71d07ad15
Diffstat (limited to 'doc/source')
-rw-r--r--doc/source/reference/defining.rst4
-rw-r--r--doc/source/reference/drivers.rst1
-rw-r--r--doc/source/reference/locations.rst4
3 files changed, 8 insertions, 1 deletions
diff --git a/doc/source/reference/defining.rst b/doc/source/reference/defining.rst
index 65a602f..59d80d5 100644
--- a/doc/source/reference/defining.rst
+++ b/doc/source/reference/defining.rst
@@ -2,7 +2,9 @@
Defining Options
==================
-Configuration options may be set on the command line or in config files.
+Configuration options may be set on the command line, in the
+:mod:`environment <oslo_config.sources._environment>`, or in config files.
+Options are processed in that order.
The schema for each option is defined using the
:class:`Opt` class or its sub-classes, for example:
diff --git a/doc/source/reference/drivers.rst b/doc/source/reference/drivers.rst
index 3790675..0c06ab1 100644
--- a/doc/source/reference/drivers.rst
+++ b/doc/source/reference/drivers.rst
@@ -10,3 +10,4 @@ Known Backend Drivers
---------------------
.. automodule:: oslo_config.sources._uri
+.. automodule:: oslo_config.sources._environment
diff --git a/doc/source/reference/locations.rst b/doc/source/reference/locations.rst
index bfade1a..40b2625 100644
--- a/doc/source/reference/locations.rst
+++ b/doc/source/reference/locations.rst
@@ -47,6 +47,10 @@ describing the location. Its value depends on the ``location``.
- ``True``
- A value set by the user on the command line.
- Empty string.
+ * - ``environment``
+ - ``True``
+ - A value set by the user in the process environment.
+ - The name of the environment variable.
Did a user set a configuration option?
======================================