mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
* When inserting a new rule in `insert_after_rule`, check if the old rule is the last rule, to avoid a list index out of range error when attempting to access the next rule. * Add a test for inserting a new rule after the last rule.
This commit is contained in:
committed by
Adam Miller
parent
158b32cd7a
commit
98260f9884
@@ -483,7 +483,10 @@ def insert_after_rule(service, old_rule, new_rule):
|
||||
if (old_rule.rule_type == rule.rule_type and
|
||||
old_rule.rule_control == rule.rule_control and
|
||||
old_rule.rule_module_path == rule.rule_module_path):
|
||||
if (new_rule.rule_type != service.rules[index + 1].rule_type or
|
||||
if (index == len(service.rules) - 1):
|
||||
service.rules.insert(len(service.rules), new_rule)
|
||||
changed = True
|
||||
elif (new_rule.rule_type != service.rules[index + 1].rule_type or
|
||||
new_rule.rule_control !=
|
||||
service.rules[index + 1].rule_control or
|
||||
new_rule.rule_module_path !=
|
||||
|
||||
Reference in New Issue
Block a user