This tool provides a extensible way to configure pre-commit hooks
to do something from running linters to spell-checking and it proved
to be useful.
Change-Id: I77cf6c85559989bd051798e601640e0039342924
Adds below things for the implementation of framework for registering and
using default policy rules.
* Policy-in-code
The framework for registering and using default policy rules.
Rules should be defined and returned from a module in
masakari/policies/, and then added to the list in masakari/policies/__init__.py.
A new context.can() method has been added for policy enforcement of
registered rules. It has the same parameters as the enforce() method
currently being used.
* Add policy sample generation
The entry point and config file necessary for using the
oslo.policy sample generation script. It also adds a tox target to
simplify the usage of it.
* Add policy documentation and sample file
Documentation and sample file for default policy in code feature.
* Hacking check for policy registration
It ensures that policy registration happens in the centralized
masakari/policies/ directory.
* Hacking check for _ENFORCER.enforce()
Hacking check in order to ensure that only registered policies
are used for authorization checks _ENFORCER.authorize should be used rather
than _ENFORCER.enforce.
* Add entry_point for oslo policy scripts
There are two helper scripts in oslo.policy to help deployers understand
their policy configuration better. With the setup.cfg entry these can be
called directly from oslo.policy.
Changes done here are with the reference of [1] at NOVA side
which is contributed by Andrew Laski and Claudiu Belu
[1] https://review.openstack.org/#/q/topic:bp/policy-in-code+project:openstack/nova+status:merged
Change-Id: If885a66d92c31be440d27d6780635800a0b12e3e
The 'yield' statement is not a function.
So it must always be followed by a space when yielding a value.
Change-Id: I518d34da400400b678448805ea19e554f48dac85
Community has decided to do not translate log messages anymore.
The motivation behind removing translation jobs for log messages
is that when operators encounters any unfamiliar situations(e.g.
nova error, keystone error etc.), searching on the Internet
based on actual log content would have more results than searching
translated log messages.
In this patch I have added hacking rule to check that logs are
not translated.
Change-Id: I90d53d617aac6839c2f2ab119847cbf24a1300e0
In newer hacking version 0.12.0 [1], we can enable some of the
non-default hacking rules (one by one), which are disabled by
default. The enabled rules are the following:
* [H106] Don’t put vim configuration in source files (off by default).
* [H203] Use assertIs(Not)None to check for None (off by default).
* [H904] Delay string interpolations at logging calls (off by default).
Enabled these hacking rules by adding them in the list of
'enable-extensions' in tox.ini [flake8] section. Removed the local
implementation of those hacking rules from hacking/checks.py.
The test-requirements.txt is already updated to use the newer
hacking version 0.12.0 with this commit:
cc44a33f3d
[1] See "Enabling off-by-default checks" section:
https://pypi.python.org/pypi/hacking/0.12.0
Change-Id: Ieccd5a84ebd80ba3313016c9caeb036eaa37769b
LOG.warn is deprecated.
LOG.warning should be used instead of LOG.warn.
So add the following hacking rule.
- [M331] LOG.warn is deprecated. Enforce use of LOG.warning.
Change-Id: I1f99331e2a51f8295eac0734aa653b4ff04ccf65
Closes-Bug: #1508442
String interpolation should be delayed to be handled
by the logging code, rather than being done
at the point of the logging call.
So add a hacking rule for it.
See the oslo i18n guideline.
* http://docs.openstack.org/developer/oslo.i18n/guidelines.html
Change-Id: Ib7d97e6edbb8069c12b22505c0d6653b4a17ec78
Closes-Bug: #1596829