Merge "Deprecate multiple config block parsing."

This commit is contained in:
Jenkins 2016-07-11 21:15:24 +00:00 committed by Gerrit Code Review
commit 41edb0aecd
2 changed files with 7 additions and 25 deletions

View File

@ -45,7 +45,7 @@ domain, using oslo_config::
app = cors.CORS(your_wsgi_application, cfg.CONF)
In your application's config file, then include a default configuration block
In your application's config file, then include a configuration block
something like this::
[cors]
@ -55,30 +55,6 @@ something like this::
allow_headers=X-Custom-Header
expose_headers=X-Custom-Header
This middleware permits you to override the rules for multiple
`allowed_origin`'s. To express this in your configuration file, first begin
with a `[cors]` group as above, into which you place your default
configuration values. Then add as many additional configuration groups as
necessary, naming them `[cors.something]` (each name must be unique). The
purpose of the suffix to `cors.` is legibility, we recommend using a
reasonable human-readable string::
[cors.ironic_webclient]
# CORS Configuration for a hypothetical ironic webclient, which overrides
# authentication
allowed_origin=https://ironic.example.com:443
allow_credentials=True
[cors.horizon]
# CORS Configuration for horizon, which uses global options.
allowed_origin=https://horizon.example.com:443
[cors.wildcard]
# CORS Configuration for the CORS specified domain wildcard, which only
# permits HTTP GET requests.
allowed_origin=*
allow_methods=GET
If your software requires specific headers or methods for proper operation, you
may include these as latent properties. These will be evaluated in addition
to any found in configuration::

View File

@ -16,6 +16,7 @@
import copy
import logging
import debtcollector
from oslo_config import cfg
from oslo_middleware import base
import six
@ -198,6 +199,11 @@ class CORS(base.ConfigurableMiddleware):
# prefixed with 'cors.'
for section in self.oslo_conf.list_all_sections():
if section.startswith('cors.'):
debtcollector.deprecate('Multiple configuration blocks are '
'deprecated and will be removed in '
'future versions. Please consolidate '
'your configuration in the [cors] '
'configuration block.')
# Register with the preconstructed defaults
self.oslo_conf.register_opts(subgroup_opts, section)
self.add_origin(**self.oslo_conf[section])