An _environment source is added that looks in os.environ for
values.
Using the environment is on by default, but can be shut down
by setting `use_env` to False when __call__ is called.
The enviroment is inspected before any other sources
of config data but the value is used after command line
arguments and before config file options.
This is done by checking both the command line and config
files and then inspecting the location of the result. If
it is command_line, we use it. If not, we use the environment
value (if any). If there's no environment value, the config
file value is used. If checking the command line and config
file results in a KeyError, the environment value is used,
if set.
The names of the environment variables follow the rules
described in oslo_config.sources._environment.
A new exception has been added: ConfigSourceValueError, this
is the superclass of the existing ConfigFileValueError. The
code in _do_get has been updated to only use
ConfigFileValueError when it is in fact a file from whence a
ValueError came.
Documentation has been updated and a rlease note created to
indicate the new functionality.
Change-Id: I3245c40ebdcc96f8e3b2dc0bab3b4aa71d07ad15
Sphinx 1.6 deprecated using the application object to perform logging
and it will be removed in the upcoming 2.0 release. This updates our
extensions to use the recommended sphinx.util.logging instead.
Change-Id: Id7da5a90b804420ece0699e4986b382e6d8bc8f2
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
Developers run all sorts of different tools within Git repositories,
any of which can leave their own special trashfiles all over the
place. We can't every hope to catalog them all, so better to
recommend developers simply configure a global core.excludesfile to
filter the irrelevant files which tend to get created by their
personal choice of tools.
To this end, remove the long-standing sections for "Mr Developer"
and "Editors" since their mere existence here sends the signal that
we welcome (and have time to review) additions for any old tool
someone ever might happen to try. Also add a comment block
explaining this, for clarity.
We can, and should of course, continue to list files created by the
tools recommended by our workflow (test frameworks called from tox,
documentation and packaging builds, et cetera).
This change is a port of I1b41efac219fca44e2548fc36633724d0ecfc0cb
from the openstack-dev/oslo-cookiecutter repository.
Change-Id: I5baba0f92e4272ba7e28f22ab6264651794ebf50
Proper handling of file lifecycle to avoid file-handler leakage.
The patch should cope with complains from Tempest:
/home/zuul/.../oslo_config/generator.py:770: ResourceWarning:
unclosed file <_io.TextIOWrapper name='/.../etc/tempest.conf.sample' mode='w' encoding='UTF-8'>
generate(conf)
Also this patch should address unstable Tempest test case
that relies on presence of config file on file system -
tempest.tests.cmd.test_verify_tempest_config.TestDiscovery.test_get_config_file()
(http://git.openstack.org/cgit/openstack/tempest/tree/tempest/tests/cmd/test_verify_tempest_config.py#n590)
Change-Id: I02a4c6a9a6422075365afe6e29a877f3f8dfad32
This patch does not provide a fix, but instead serves to illustrate
several use cases where positional arguments do not behave correctly on
the CLI.
Change-Id: Ibdb05066b95a285f6618c861eb4d38465dbf0d02
Related-Bug: 1676989
d.keys() no longer returns a copy of the keys in Python 3.
This is part of PEP 3106.
Change-Id: Ie4897109c87d6dc2952c2eb35b83fe368fb31803
Closes-Bug: #1796163
Because sample_default makes the generator silently ignore the
actual default value, it is possible for it to cause confusion for
users. This change adds a message to the generated opt help to let
them know that the documented default may not be the actual default.
Change-Id: Ib48d5dd1d18546b5464e9e096c47d1e3d67be57c
Closes-Bug: 1795729
In some cases it may be easier to generate a machine-readable sample
config file and use that to validate a config file instead of using
the config generator directly.
Change-Id: I7afe65c4abcbf8cdf1f5299ed3826c7205074e28
This is a very basic config validator that just reads the provided
config file and compares it with the machine readable sample config
data from the config generator to find any options that are not
defined in the project. It will also warn about deprecated options
in use in the provided file.
Change-Id: I410b16ffcfb069140bd51dffaba7d56eada1a7e9
This replaces the deprecated (in python 3.2) unittest.TestCase method
assertRaisesRegexp() with assertRaisesRegex().
Change-Id: Iba92ef7a76d9392750a95e3bd603f364de4ec890
Signed-off-by: Chuck Short <chucks@redhat.com>
While multi-line help texts for opts were already handled properly, the
same was not true of groups. Close this gap, allowing us to resolve the
FIXME in the process.
Change-Id: Ic564dbff983205134386ba5b7047d6d811c60ef1
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
The functionality previously added here was broken as it did not include
a required newline. Rather than fix it, modify the whole thing to print
to logs instead of a temporary file. This should achieve the same effect
with less side effects.
Change-Id: I74d11a54d57d30aab7f97f4fcce9fee0b7d87cbc
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Closes-Bug: #1782316
This is a mechanically generated patch to add a functional test job
running under Python 3 as part of the python3-first goal.
See the python3-first goal document for details:
https://governance.openstack.org/tc/goals/stein/python3-first.html
Change-Id: Icfe03bc959cf8a0ae4911fb76c79fe74d5ba3e57
Story: #2002586
Task: #24322
This is a mechanically generated patch to complete step 1 of moving
the zuul job settings out of project-config and into each project
repository.
Because there will be a separate patch on each branch, the branch
specifiers for branch-specific jobs have been removed.
See the python3-first goal document for details:
https://governance.openstack.org/tc/goals/stein/python3-first.html
Change-Id: I3cf9088f49df81516e2fe1301cdd56d12daaaae9
Story: #2003250
A typo resulted in us dumping the help text for opts as many times as
there were lines in the group help text. Resolve this.
Change-Id: I7a6506235834022fa76588e55ec60921b1ae673f
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Closes-Bug: #1782253
The cfg module is very large, and starts with a huge block of
documentation. This patch moves that information into separate files
in the reference section of the docs. A few formatting fixes need to
be made to have it build cleanly, but the content is not changed in a
substantive way.
Change-Id: I86aa90bbf180b5dc9acbcedb024e5361d49954c3
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Add a separate cache for values coming from external sources,
this will protect us from having options from external sources
mutated when we reload the configuration files
Change-Id: Icf72f4e1745a0ddf53e661cc08d0fe7428cd9a41
Blueprint: oslo-config-drivers
In preparation for adding another conf option that would have needed to
be kwarg'd all the way down the call stack to the .format method, this
patch removes the existing `minimal` and `summarize` kwargs from the
methods in that call stack and instead makes them instance attributes of
generator._OptFormatter, which is now initialized with the whole
ConfigOpts object rather than those individual options.
This is just a refactor. There is no functional change (assuming nobody
is being naughty and consuming the private _OptFormatter class).
Change-Id: Ide0f1c6d79d506b979b54e6446786ea9ff51c8d5
When we ask for a list of options from a drivere for generating the
sample config or documentation, we want to insert the actual 'driver'
option at the front of the list. This keeps each driver from having to
do that, and allows us to generate the sample with good
defaults. However, if a driver returns us a static data structure, we
do not want to modify *that* set of data, because the driver tests
will need the original structure intact. So, have list_opts() deepcopy
the data it is given, again to avoid having to ensure each driver
author does that copy.
This change also requires updating the test for list_opts() for the
URI driver to no longer assume the 'driver' option will be in the
results. At the same time I am reordering the arguments to
assertEqual() so that the expected value is listed first and renaming
the variable holding the actual values from the discovery call.
Change-Id: Ie8c1bc606f5f69a72b2383200a40b26e252067a9
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
New documentation sections explaning how to use the backend
drivers for oslo.config, also include explanation on how to
use the remote_file driver.
Change-Id: I45fc2155f6fe2d8bee058dac880afba8bb9bfd53
Blueprint: oslo-config-drivers
Have the main _list_opts caller construct the driver option so
individual drivers do not need to repeat that.
Add choices with descriptions when emitting samples. We don't really
care about those for the runtime use, but they improve the output in
the config generator and documentation.
Use an OptGroup with the driver_option and dynamic_group_owner options
set instead of just a group name when describing the options.
Add sample_default values for some of the options in the URI driver.
Change-Id: I14c0a046e6c70a9108308db70a4efb70613d5bb3
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
We have a section in the reference guide showing the configuration
options built into oslo.config. Move that to the configuration guide
instead so it is linked from the Configuration Guide list at
https://docs.openstack.org/$series/configuration/ like the similar
documentation for other libraries.
Change-Id: I7da159cfaa643c2cc094f6fb1c0aeaa956f3eb77
Signed-off-by: Doug Hellmann <doug@doughellmann.com>