register the built-in options for the config generator to find
Change-Id: Ic570fece888a1a115bec976b368d0efb9b1b4686
This commit is contained in:
parent
302dca6979
commit
d5f877ed0e
|
@ -0,0 +1,25 @@
|
||||||
|
# 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_config import cfg
|
||||||
|
|
||||||
|
|
||||||
|
def list_opts():
|
||||||
|
default_config_files = [
|
||||||
|
'~/.project/project.conf',
|
||||||
|
'~/project.conf',
|
||||||
|
'/etc/project/project.conf',
|
||||||
|
'/etc/project.conf',
|
||||||
|
]
|
||||||
|
return [
|
||||||
|
(None, cfg.ConfigOpts._make_config_options(default_config_files)),
|
||||||
|
]
|
|
@ -1948,17 +1948,16 @@ class ConfigOpts(collections.Mapping):
|
||||||
|
|
||||||
return prog, default_config_files
|
return prog, default_config_files
|
||||||
|
|
||||||
def _setup(self, project, prog, version, usage, default_config_files):
|
@staticmethod
|
||||||
"""Initialize a ConfigOpts object for option parsing."""
|
def _make_config_options(default_config_files):
|
||||||
|
return [
|
||||||
self._config_opts = [
|
|
||||||
_ConfigFileOpt('config-file',
|
_ConfigFileOpt('config-file',
|
||||||
default=default_config_files,
|
default=default_config_files,
|
||||||
metavar='PATH',
|
metavar='PATH',
|
||||||
help=('Path to a config file to use. Multiple '
|
help=('Path to a config file to use. Multiple '
|
||||||
'config files can be specified, with values '
|
'config files can be specified, with values '
|
||||||
'in later files taking precedence. The '
|
'in later files taking precedence. Defaults '
|
||||||
'default files used are: %(default)s.')),
|
'to %(default)s.')),
|
||||||
_ConfigDirOpt('config-dir',
|
_ConfigDirOpt('config-dir',
|
||||||
metavar='DIR',
|
metavar='DIR',
|
||||||
help='Path to a config directory to pull *.conf '
|
help='Path to a config directory to pull *.conf '
|
||||||
|
@ -1970,6 +1969,11 @@ class ConfigOpts(collections.Mapping):
|
||||||
'over-ridden options in the directory take '
|
'over-ridden options in the directory take '
|
||||||
'precedence.'),
|
'precedence.'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def _setup(self, project, prog, version, usage, default_config_files):
|
||||||
|
"""Initialize a ConfigOpts object for option parsing."""
|
||||||
|
|
||||||
|
self._config_opts = self._make_config_options(default_config_files)
|
||||||
self.register_cli_opts(self._config_opts)
|
self.register_cli_opts(self._config_opts)
|
||||||
|
|
||||||
self.project = project
|
self.project = project
|
||||||
|
|
|
@ -30,6 +30,8 @@ setup-hooks =
|
||||||
[entry_points]
|
[entry_points]
|
||||||
console_scripts =
|
console_scripts =
|
||||||
oslo-config-generator = oslo_config.generator:main
|
oslo-config-generator = oslo_config.generator:main
|
||||||
|
oslo.config.opts =
|
||||||
|
oslo.config = oslo_config._list_opts:list_opts
|
||||||
|
|
||||||
[build_sphinx]
|
[build_sphinx]
|
||||||
source-dir = doc/source
|
source-dir = doc/source
|
||||||
|
|
Loading…
Reference in New Issue