diff options
-rw-r--r-- | .zuul.d/project.yaml | 2 | ||||
-rw-r--r-- | doc/source/configuration/format.rst | 2 | ||||
-rw-r--r-- | doc/source/index.rst | 7 | ||||
-rw-r--r-- | lower-constraints.txt | 2 | ||||
-rw-r--r-- | oslo_config/cfg.py | 5 | ||||
-rw-r--r-- | oslo_config/sources/__init__.py | 16 | ||||
-rw-r--r-- | oslo_config/sources/_environment.py | 11 | ||||
-rw-r--r-- | oslo_config/sphinxconfiggen.py | 4 | ||||
-rw-r--r-- | oslo_config/sphinxext.py | 4 | ||||
-rw-r--r-- | oslo_config/tests/test_cfg.py | 2 | ||||
-rw-r--r-- | oslo_config/tests/test_generator.py | 2 | ||||
-rw-r--r-- | oslo_config/tests/test_sources.py | 16 | ||||
-rw-r--r-- | oslo_config/tests/test_sphinxconfiggen.py | 3 | ||||
-rw-r--r-- | oslo_config/tests/test_sphinxext.py | 2 | ||||
-rw-r--r-- | oslo_config/tests/test_validator.py | 3 | ||||
-rw-r--r-- | releasenotes/source/index.rst | 1 | ||||
-rw-r--r-- | releasenotes/source/ussuri.rst | 6 | ||||
-rw-r--r-- | setup.cfg | 1 | ||||
-rw-r--r-- | test-requirements.txt | 3 |
19 files changed, 60 insertions, 32 deletions
diff --git a/.zuul.d/project.yaml b/.zuul.d/project.yaml index a60d493..2c16442 100644 --- a/.zuul.d/project.yaml +++ b/.zuul.d/project.yaml @@ -3,7 +3,7 @@ - check-requirements - lib-forward-testing-python3 - openstack-lower-constraints-jobs - - openstack-python3-ussuri-jobs + - openstack-python3-victoria-jobs - periodic-stable-jobs - publish-openstack-docs-pti - release-notes-jobs-python3 diff --git a/doc/source/configuration/format.rst b/doc/source/configuration/format.rst index 9254a1e..7467117 100644 --- a/doc/source/configuration/format.rst +++ b/doc/source/configuration/format.rst @@ -155,7 +155,7 @@ option, in this case as ``controller:5672``. # RabbitMQ HA cluster host:port pairs. (list value) rabbit_hosts = $rabbit_host:$rabbit_port -To avoid substitution, use ``$$``, it is replaced by a single ``$``. +To avoid substitution, escape the ``$`` with ``$$`` or ``\$``. For example, if your LDAP DNS password is ``$xkj432``, specify it, as follows: .. code-block:: ini diff --git a/doc/source/index.rst b/doc/source/index.rst index af24458..9332680 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -16,6 +16,13 @@ Contents cli/index contributor/index + +Release Notes +============= + +Read also the `oslo.config Release Notes +<https://docs.openstack.org/releasenotes/oslo.config/>`_. + Indices and tables ================== diff --git a/lower-constraints.txt b/lower-constraints.txt index 788b173..aca80eb 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -18,7 +18,6 @@ keystoneauth1==3.4.0 linecache2==1.0.0 MarkupSafe==1.0 mccabe==0.2.1 -mock==3.0.0 mox3==0.20.0 mypy==0.720 netaddr==0.7.18 @@ -40,7 +39,6 @@ requests==2.18.0 requests_mock==1.5.0 requestsexceptions==1.2.0 rfc3986==1.2.0 -six==1.10.0 smmap==0.9.0 snowballstemmer==1.2.1 Sphinx==1.8.0 diff --git a/oslo_config/cfg.py b/oslo_config/cfg.py index 638e4ff..5324e52 100644 --- a/oslo_config/cfg.py +++ b/oslo_config/cfg.py @@ -2678,6 +2678,7 @@ class ConfigOpts(abc.Mapping): namespace = self._namespace if namespace is not None: try: + alt_loc = None try: val, alt_loc = opt._get_from_namespace(namespace, group_name) @@ -2692,6 +2693,10 @@ class ConfigOpts(abc.Mapping): if val != sources._NoValue: return (convert(val), alt_loc) except KeyError: # nosec: Valid control flow instruction + alt_loc = LocationInfo( + Locations.environment, + self._env_driver.get_name(group_name, name), + ) # If there was a KeyError looking at config files or # command line, retry the env_val. if env_val[0] != sources._NoValue: diff --git a/oslo_config/sources/__init__.py b/oslo_config/sources/__init__.py index e3e99af..92b557d 100644 --- a/oslo_config/sources/__init__.py +++ b/oslo_config/sources/__init__.py @@ -23,22 +23,6 @@ class of type :class:`ConfigurationSource`. **IMPORTANT:** At this point, all backend drivers are only able to provide immutable values. This protects applications and services from having options in external sources mutated when they reload configuration files. - -Abstract Classes ----------------- - -The Driver Class -================ - -.. autoclass:: ConfigurationSourceDriver - :members: - -The Configuration Source Class -============================== - -.. autoclass:: ConfigurationSource - :members: - """ import abc diff --git a/oslo_config/sources/_environment.py b/oslo_config/sources/_environment.py index 19dc093..7caaa43 100644 --- a/oslo_config/sources/_environment.py +++ b/oslo_config/sources/_environment.py @@ -77,12 +77,19 @@ class EnvironmentConfigurationSource(sources.ConfigurationSource): """A configuration source for options in the environment.""" @staticmethod - def _make_name(group_name, option_name): + def get_name(group_name, option_name): + """Return the expected environment variable name for the given option. + + :param group_name: The group name or None. Defaults to 'DEFAULT' if + None. + :param option_name: The option name. + :returns: Th expected environment variable name. + """ group_name = group_name or 'DEFAULT' return 'OS_{}__{}'.format(group_name.upper(), option_name.upper()) def get(self, group_name, option_name, opt): - env_name = self._make_name(group_name, option_name) + env_name = self.get_name(group_name, option_name) try: value = os.environ[env_name] loc = oslo_config.cfg.LocationInfo( diff --git a/oslo_config/sphinxconfiggen.py b/oslo_config/sphinxconfiggen.py index ff7172c..616e857 100644 --- a/oslo_config/sphinxconfiggen.py +++ b/oslo_config/sphinxconfiggen.py @@ -91,3 +91,7 @@ def setup(app): app.add_config_value('config_generator_config_file', None, 'env') app.add_config_value('sample_config_basename', None, 'env') app.connect('builder-inited', generate_sample) + return { + 'parallel_read_safe': True, + 'parallel_write_safe': True, + } diff --git a/oslo_config/sphinxext.py b/oslo_config/sphinxext.py index 905490c..4a11163 100644 --- a/oslo_config/sphinxext.py +++ b/oslo_config/sphinxext.py @@ -508,3 +508,7 @@ def setup(app): oslo_i18n.enable_lazy(False) app.add_directive('show-options', ShowOptionsDirective) app.add_domain(ConfigDomain) + return { + 'parallel_read_safe': True, + 'parallel_write_safe': True, + } diff --git a/oslo_config/tests/test_cfg.py b/oslo_config/tests/test_cfg.py index 98bd8e3..ac45780 100644 --- a/oslo_config/tests/test_cfg.py +++ b/oslo_config/tests/test_cfg.py @@ -21,9 +21,9 @@ import os import shutil import sys import tempfile +from unittest import mock import fixtures -import mock from oslotest import base import testscenarios diff --git a/oslo_config/tests/test_generator.py b/oslo_config/tests/test_generator.py index 7db7c60..7cb354e 100644 --- a/oslo_config/tests/test_generator.py +++ b/oslo_config/tests/test_generator.py @@ -15,9 +15,9 @@ import io import sys import textwrap +from unittest import mock import fixtures -import mock from oslotest import base import tempfile import testscenarios diff --git a/oslo_config/tests/test_sources.py b/oslo_config/tests/test_sources.py index 656f61e..2da73da 100644 --- a/oslo_config/tests/test_sources.py +++ b/oslo_config/tests/test_sources.py @@ -15,6 +15,7 @@ import os from oslotest import base from requests import HTTPError import requests_mock +import testtools from oslo_config import _list_opts from oslo_config import cfg @@ -120,10 +121,13 @@ class TestEnvironmentConfigurationSource(base.BaseTestCase): self.conf = cfg.ConfigOpts() self.conf_fixture = self.useFixture(fixture.Config(self.conf)) self.conf.register_opt(cfg.StrOpt('bar'), 'foo') + self.conf.register_opt(cfg.StrOpt('baz', regex='^[a-z].*$'), 'foo') def cleanup(): - if 'OS_FOO__BAR' in os.environ: - del os.environ['OS_FOO__BAR'] + for env in ('OS_FOO__BAR', 'OS_FOO__BAZ'): + if env in os.environ: + del os.environ[env] + self.addCleanup(cleanup) def test_simple_environment_get(self): @@ -171,6 +175,14 @@ class TestEnvironmentConfigurationSource(base.BaseTestCase): self.conf(args=[], use_env=True) self.assertEqual(env_value, self.conf['foo']['bar']) + def test_invalid_env(self): + self.conf(args=[]) + env_value = 'ABC' + os.environ['OS_FOO__BAZ'] = env_value + + with testtools.ExpectedException(cfg.ConfigSourceValueError): + self.conf['foo']['baz'] + def make_uri(name): return "https://oslo.config/{}.conf".format(name) diff --git a/oslo_config/tests/test_sphinxconfiggen.py b/oslo_config/tests/test_sphinxconfiggen.py index 982641e..e4ddcba 100644 --- a/oslo_config/tests/test_sphinxconfiggen.py +++ b/oslo_config/tests/test_sphinxconfiggen.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslotest import base from oslo_config import sphinxconfiggen diff --git a/oslo_config/tests/test_sphinxext.py b/oslo_config/tests/test_sphinxext.py index b35af71..340ee4e 100644 --- a/oslo_config/tests/test_sphinxext.py +++ b/oslo_config/tests/test_sphinxext.py @@ -11,8 +11,8 @@ # under the License. import textwrap +from unittest import mock -import mock from oslotest import base from oslo_config import cfg diff --git a/oslo_config/tests/test_validator.py b/oslo_config/tests/test_validator.py index a2ffde7..de912ac 100644 --- a/oslo_config/tests/test_validator.py +++ b/oslo_config/tests/test_validator.py @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslotest import base from oslo_config import cfg diff --git a/releasenotes/source/index.rst b/releasenotes/source/index.rst index a2b4deb..2051f56 100644 --- a/releasenotes/source/index.rst +++ b/releasenotes/source/index.rst @@ -6,6 +6,7 @@ :maxdepth: 1 unreleased + ussuri train stein rocky diff --git a/releasenotes/source/ussuri.rst b/releasenotes/source/ussuri.rst new file mode 100644 index 0000000..e21e50e --- /dev/null +++ b/releasenotes/source/ussuri.rst @@ -0,0 +1,6 @@ +=========================== +Ussuri Series Release Notes +=========================== + +.. release-notes:: + :branch: stable/ussuri @@ -18,6 +18,7 @@ classifier = Programming Language :: Python :: 3 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 Programming Language :: Python :: 3 :: Only Programming Language :: Python :: Implementation :: CPython diff --git a/test-requirements.txt b/test-requirements.txt index 8441e70..985a9da 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -21,9 +21,6 @@ oslo.log>=3.36.0 # Apache-2.0 # deps = {[testenv]deps} coverage coverage!=4.4,>=4.0 # Apache-2.0 -# we can switch to unittest.mock once we drop support for Python 3.6 as that -# includes https://bugs.python.org/issue32933 -mock>=3.0.0 # BSD requests_mock>=1.5.0 # Apache-2.0 # Bandit security code scanner |