diff options
author | Lance Bragstad <lbragstad@gmail.com> | 2019-07-25 16:28:01 +0000 |
---|---|---|
committer | Ben Nemec <bnemec@redhat.com> | 2019-07-25 19:17:33 +0000 |
commit | 9641e5ca0d758376fb7f7f5156056d5206d71046 (patch) | |
tree | 3debc74165a27eb4baebb53b5f36c3b7e00fb4b2 /oslo_policy/generator.py | |
parent | b7da7a92ad558947d6a133800f6049578e450b6a (diff) | |
download | oslo-policy-9641e5ca0d758376fb7f7f5156056d5206d71046.tar.gz |
Only alias when policy names change
Previously, oslo.policy would generate policy files with aliased names
in the event the name was changing for backwards compatibility. This
isn't needed if the name isn't changing and only the check string is
changing.
This patch adds a conditional to the generator logic that only aliases
the old name to the new name if the name is changing. Otherwise, it
only outputs comments about the deprecation.
Co-Authored-By: Ben Nemec <bnemec@redhat.com>
Change-Id: I89ff60354e4751a5096832023441d2e6166db92a
Diffstat (limited to 'oslo_policy/generator.py')
-rw-r--r-- | oslo_policy/generator.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/oslo_policy/generator.py b/oslo_policy/generator.py index 1ea768e..bd75389 100644 --- a/oslo_policy/generator.py +++ b/oslo_policy/generator.py @@ -193,12 +193,19 @@ def _format_rule_default_yaml(default, include_help=True): 'check_str': default.check_str, 'reason': default.deprecated_reason} - text = ( - '%(text)s%(deprecated_text)s\n"%(old_name)s": "rule:%(name)s"\n' - ) % {'text': text, - 'deprecated_text': _format_help_text(deprecated_text), - 'old_name': default.deprecated_rule.name, - 'name': default.name} + if default.name != default.deprecated_rule.name: + text = ( + '%(text)s%(deprecated_text)s\n"%(old_name)s": "rule:%(name)s"' + '\n' + ) % {'text': text, + 'deprecated_text': _format_help_text(deprecated_text), + 'old_name': default.deprecated_rule.name, + 'name': default.name} + else: + text = ( + '%(text)s%(deprecated_text)s\n' + ) % {'text': text, + 'deprecated_text': _format_help_text(deprecated_text)} return text |