Skip to content

Commit

Permalink
[PR #9202/55d714da backport][stable-9] keycloak_clientscope_type: sor…
Browse files Browse the repository at this point in the history
…t default and optional clientscope lists before diff (#9221)

keycloak_clientscope_type: sort default and optional clientscope lists before diff (#9202)

* sort default and optional clientscope lists before diff

* add changelog fragment

(cherry picked from commit 55d714d)

Co-authored-by: fgruenbauer <[email protected]>
  • Loading branch information
patchback[bot] and fgruenbauer authored Dec 2, 2024
1 parent c349861 commit aa0df4d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- keycloak_clientscope_type - sort the default and optional clientscope lists to improve the diff (https://github.com/ansible-collections/community.general/pull/9202).
11 changes: 10 additions & 1 deletion plugins/modules/keycloak_clientscope_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,15 @@ def extract_field(dictionary, field='name'):
return [cs[field] for cs in dictionary]


def normalize_scopes(scopes):
scopes_copy = scopes.copy()
if isinstance(scopes_copy.get('default_clientscopes'), list):
scopes_copy['default_clientscopes'] = sorted(scopes_copy['default_clientscopes'])
if isinstance(scopes_copy.get('optional_clientscopes'), list):
scopes_copy['optional_clientscopes'] = sorted(scopes_copy['optional_clientscopes'])
return scopes_copy


def main():
"""
Module keycloak_clientscope_type
Expand Down Expand Up @@ -244,7 +253,7 @@ def main():
})

if module._diff:
result['diff'] = dict(before=result['existing'], after=result['proposed'])
result['diff'] = dict(before=normalize_scopes(result['existing']), after=normalize_scopes(result['proposed']))

default_clientscopes_add = clientscopes_to_add(default_clientscopes_existing, default_clientscopes_real)
optional_clientscopes_add = clientscopes_to_add(optional_clientscopes_existing, optional_clientscopes_real)
Expand Down

0 comments on commit aa0df4d

Please sign in to comment.