diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-08-27 12:53:18 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-08-27 12:53:18 +0000 |
commit | b73aa5c3abcea74716e236e8fd41475a5dc8dbdd (patch) | |
tree | 1c1b46b494368bbe92d1c1bdb0bde910aa47de19 | |
parent | 6e7167cf63e1b45ad95cf63b3b9d3d8d3312b7a0 (diff) | |
parent | ea893e8ba417aeb13455acfda30b8337159b8536 (diff) | |
download | oslo-middleware-b73aa5c3abcea74716e236e8fd41475a5dc8dbdd.tar.gz |
Merge "Split option discovery function by middleware"2.8.0
-rw-r--r-- | doc/source/api.rst | 13 | ||||
-rwxr-xr-x | doc/source/conf.py | 5 | ||||
-rw-r--r-- | doc/source/cors.rst | 5 | ||||
-rw-r--r-- | oslo_middleware/opts.py | 83 | ||||
-rw-r--r-- | oslo_middleware/tests/test_opts.py | 31 | ||||
-rw-r--r-- | setup.cfg | 3 |
6 files changed, 136 insertions, 4 deletions
diff --git a/doc/source/api.rst b/doc/source/api.rst index 38cd96c..50ad06d 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -4,3 +4,16 @@ .. automodule:: oslo_middleware :members: + +Configuration Options +===================== + +RequestBodySizeLimiter +~~~~~~~~~~~~~~~~~~~~~~ + +.. show-options:: oslo.middleware.sizelimit + +SSLMiddleware +~~~~~~~~~~~~~ + +.. show-options:: oslo.middleware.ssl diff --git a/doc/source/conf.py b/doc/source/conf.py index c5178f1..6265ab6 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -23,7 +23,8 @@ sys.path.insert(0, os.path.abspath('../..')) extensions = [ 'sphinx.ext.autodoc', #'sphinx.ext.intersphinx', - 'oslosphinx' + 'oslosphinx', + 'oslo_config.sphinxext', ] # autodoc generation is a bit aggressive and a nuisance when doing heavy @@ -72,4 +73,4 @@ latex_documents = [ ] # Example configuration for intersphinx: refer to the Python standard library. -#intersphinx_mapping = {'http://docs.python.org/': None}
\ No newline at end of file +#intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/doc/source/cors.rst b/doc/source/cors.rst index 09f5d77..890f7fd 100644 --- a/doc/source/cors.rst +++ b/doc/source/cors.rst @@ -105,6 +105,11 @@ will add CORS support. To add multiple domains, simply add another filter.:: expose_headers=Content-Type,Cache-Control,Content-Language,Expires,Last-Modified,Pragma,X-Custom-Header +Configuration Options +--------------------- + +.. show-options:: oslo.middleware.cors + Module Documentation -------------------- diff --git a/oslo_middleware/opts.py b/oslo_middleware/opts.py index c19f272..883fb90 100644 --- a/oslo_middleware/opts.py +++ b/oslo_middleware/opts.py @@ -15,10 +15,14 @@ __all__ = [ 'list_opts', + 'list_opts_sizelimit', + 'list_opts_ssl', + 'list_opts_cors' ] import copy +import itertools from oslo_middleware import cors from oslo_middleware import sizelimit @@ -26,7 +30,83 @@ from oslo_middleware import ssl def list_opts(): - """Return a list of oslo.config options available in the library. + """Return a list of oslo.config options for ALL of the middleware classes. + + The returned list includes all oslo.config options which may be registered + at runtime by the library. + + Each element of the list is a tuple. The first element is the name of the + group under which the list of elements in the second element will be + registered. A group name of None corresponds to the [DEFAULT] group in + config files. + + This function is also discoverable via the 'oslo.concurrency' entry point + under the 'oslo.config.opts' namespace. + + The purpose of this is to allow tools like the Oslo sample config file + generator to discover the options exposed to users by this library. + + :returns: a list of (group_name, opts) tuples + """ + return list( + itertools.chain( + list_opts_sizelimit(), + list_opts_ssl(), + list_opts_cors(), + ) + ) + + +def list_opts_sizelimit(): + """Return a list of oslo.config options for the sizelimit middleware. + + The returned list includes all oslo.config options which may be registered + at runtime by the library. + + Each element of the list is a tuple. The first element is the name of the + group under which the list of elements in the second element will be + registered. A group name of None corresponds to the [DEFAULT] group in + config files. + + This function is also discoverable via the 'oslo.concurrency' entry point + under the 'oslo.config.opts' namespace. + + The purpose of this is to allow tools like the Oslo sample config file + generator to discover the options exposed to users by this library. + + :returns: a list of (group_name, opts) tuples + """ + return [ + ('oslo_middleware', copy.deepcopy(sizelimit._opts)), + ] + + +def list_opts_ssl(): + """Return a list of oslo.config options for the sizelimit middleware. + + The returned list includes all oslo.config options which may be registered + at runtime by the library. + + Each element of the list is a tuple. The first element is the name of the + group under which the list of elements in the second element will be + registered. A group name of None corresponds to the [DEFAULT] group in + config files. + + This function is also discoverable via the 'oslo.concurrency' entry point + under the 'oslo.config.opts' namespace. + + The purpose of this is to allow tools like the Oslo sample config file + generator to discover the options exposed to users by this library. + + :returns: a list of (group_name, opts) tuples + """ + return [ + ('oslo_middleware', copy.deepcopy(ssl.OPTS)), + ] + + +def list_opts_cors(): + """Return a list of oslo.config options for the cors middleware. The returned list includes all oslo.config options which may be registered at runtime by the library. @@ -45,7 +125,6 @@ def list_opts(): :returns: a list of (group_name, opts) tuples """ return [ - ('oslo_middleware', copy.deepcopy(sizelimit._opts + ssl.OPTS)), ('cors', copy.deepcopy(cors.CORS_OPTS)), ('cors.subdomain', copy.deepcopy(cors.CORS_OPTS)) ] diff --git a/oslo_middleware/tests/test_opts.py b/oslo_middleware/tests/test_opts.py new file mode 100644 index 0000000..763d550 --- /dev/null +++ b/oslo_middleware/tests/test_opts.py @@ -0,0 +1,31 @@ +# Copyright (c) 2015 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslo_middleware import opts +from oslotest.base import BaseTestCase + + +class TestOptionDiscovery(BaseTestCase): + + def test_all(self): + opts.list_opts() + + def test_sizelimit(self): + opts.list_opts_sizelimit() + + def test_cors(self): + opts.list_opts_cors() + + def test_ssl(self): + opts.list_opts_ssl() @@ -30,6 +30,9 @@ namespace_packages = [entry_points] oslo.config.opts = oslo.middleware = oslo_middleware.opts:list_opts + oslo.middleware.cors = oslo_middleware.opts:list_opts_cors + oslo.middleware.sizelimit = oslo_middleware.opts:list_opts_sizelimit + oslo.middleware.ssl = oslo_middleware.opts:list_opts_ssl oslo.middleware.healthcheck = disable_by_file = oslo_middleware.healthcheck.disable_by_file:DisableByFileHealthcheck |