From 50a8b1b937041f59aea1577203a9863a9d7784ef Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 24 Sep 2015 20:07:03 +0000 Subject: [PATCH] make configuration options discoverable Add an entry point to make the configuration options defined in the library discoverable for the sample configuration generator. Add the configuration options to the library documentation. Change-Id: I5b49fef1d0363d8887a84cdc3cec242efe1b9084 --- doc/source/conf.py | 3 ++- doc/source/index.rst | 1 + doc/source/opts.rst | 9 ++++++++ oslo_versionedobjects/_options.py | 34 +++++++++++++++++++++++++++++++ setup.cfg | 4 ++++ 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 doc/source/opts.rst create mode 100644 oslo_versionedobjects/_options.py diff --git a/doc/source/conf.py b/doc/source/conf.py index b9b4d46b..cff3f2e3 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 diff --git a/doc/source/index.rst b/doc/source/index.rst index bd110977..94dc98ee 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -22,6 +22,7 @@ Contents installation api/index usage + opts contributing Release Notes diff --git a/doc/source/opts.rst b/doc/source/opts.rst new file mode 100644 index 00000000..f6449ab5 --- /dev/null +++ b/doc/source/opts.rst @@ -0,0 +1,9 @@ +======================= + Configuration Options +======================= + +oslo.versionedobjects uses oslo.config to define and manage +configuration options to allow the deployer to control how an +application using oslo.versionedobjects behaves. + +.. show-options:: oslo.versionedobjects diff --git a/oslo_versionedobjects/_options.py b/oslo_versionedobjects/_options.py new file mode 100644 index 00000000..a54dfcce --- /dev/null +++ b/oslo_versionedobjects/_options.py @@ -0,0 +1,34 @@ +# 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. + +import copy + +from oslo_versionedobjects import exception + + +def list_opts(): + """Returns a list of oslo.config options available in the library. + + 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. + + 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_versionedobjects', copy.deepcopy(exception.exc_log_opts))] diff --git a/setup.cfg b/setup.cfg index 95106801..f1c6c486 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,6 +22,10 @@ classifier = packages = oslo_versionedobjects +[entry_points] +oslo.config.opts = + oslo.versionedobjects = oslo_versionedobjects._options:list_opts + [extras] fixtures = mock>=1.2