register the built-in options for the config generator to find
Change-Id: Ic570fece888a1a115bec976b368d0efb9b1b4686
This commit is contained in:
parent
302dca6979
commit
d5f877ed0e
25
oslo_config/_list_opts.py
Normal file
25
oslo_config/_list_opts.py
Normal file
@ -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
|
||||
|
||||
def _setup(self, project, prog, version, usage, default_config_files):
|
||||
"""Initialize a ConfigOpts object for option parsing."""
|
||||
|
||||
self._config_opts = [
|
||||
@staticmethod
|
||||
def _make_config_options(default_config_files):
|
||||
return [
|
||||
_ConfigFileOpt('config-file',
|
||||
default=default_config_files,
|
||||
metavar='PATH',
|
||||
help=('Path to a config file to use. Multiple '
|
||||
'config files can be specified, with values '
|
||||
'in later files taking precedence. The '
|
||||
'default files used are: %(default)s.')),
|
||||
'in later files taking precedence. Defaults '
|
||||
'to %(default)s.')),
|
||||
_ConfigDirOpt('config-dir',
|
||||
metavar='DIR',
|
||||
help='Path to a config directory to pull *.conf '
|
||||
@ -1970,6 +1969,11 @@ class ConfigOpts(collections.Mapping):
|
||||
'over-ridden options in the directory take '
|
||||
'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.project = project
|
||||
|
Loading…
x
Reference in New Issue
Block a user