Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed roles diff when the roles are provided as a list #737

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/diff_roles_fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- Fixed roles diff when the roles are provided as a list, in a single entry
15 changes: 15 additions & 0 deletions plugins/lookup/controller_object_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,21 @@ def run(self, terms, variables=None, **kwargs):
for item in list_to_remove:
compare_list_reduced.remove(item)
compare_list_reduced.extend(list_to_extend)
# Expand all compare list elements when roles is provided as list
list_to_extend.clear()
list_to_remove.clear()
for item in compare_list_reduced:
expanded = False
dupitems = ["roles", "role"]
if "roles" in item:
for role in item["roles"]:
list_to_extend.append(self.map_item(item, "role", role, dupitems))
expanded = True
if expanded:
list_to_remove.append(item)
for item in list_to_remove:
compare_list_reduced.remove(item)
compare_list_reduced.extend(list_to_extend)
elif (
api_list[0]["type"] != "organization"
and api_list[0]["type"] != "user"
Expand Down
Loading