keycloak_clientscope_type fix checkmode (#9093)
* fix check_mode on set keycloak client scope type (#9092) * add changelog fragment (#9092) * update changelog fragment (#9092) * compact code: make one line conditions with list comprehension and any() Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * fix syntax error: remove extra ')' * fix changelog fragment type Co-authored-by: Felix Fontein <felix@fontein.de> * add issue's link in changelog fragment Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Felix Fontein <felix@fontein.de>pull/9098/head
parent
cecaa1840d
commit
8fc11fe88f
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- keycloak_clientscope_type - fix detect changes in check mode (https://github.com/ansible-collections/community.general/issues/9092, https://github.com/ansible-collections/community.general/pull/9093).
|
|
@ -246,15 +246,19 @@ def main():
|
|||
if module._diff:
|
||||
result['diff'] = dict(before=result['existing'], after=result['proposed'])
|
||||
|
||||
if module.check_mode:
|
||||
module.exit_json(**result)
|
||||
|
||||
default_clientscopes_add = clientscopes_to_add(default_clientscopes_existing, default_clientscopes_real)
|
||||
optional_clientscopes_add = clientscopes_to_add(optional_clientscopes_existing, optional_clientscopes_real)
|
||||
|
||||
default_clientscopes_delete = clientscopes_to_delete(default_clientscopes_existing, default_clientscopes_real)
|
||||
optional_clientscopes_delete = clientscopes_to_delete(optional_clientscopes_existing, optional_clientscopes_real)
|
||||
|
||||
result["changed"] = any(len(x) > 0 for x in [
|
||||
default_clientscopes_add, optional_clientscopes_add, default_clientscopes_delete, optional_clientscopes_delete
|
||||
])
|
||||
|
||||
if module.check_mode:
|
||||
module.exit_json(**result)
|
||||
|
||||
# first delete so clientscopes can change type
|
||||
for clientscope in default_clientscopes_delete:
|
||||
kc.delete_default_clientscope(clientscope['id'], realm, client_id)
|
||||
|
@ -266,13 +270,6 @@ def main():
|
|||
for clientscope in optional_clientscopes_add:
|
||||
kc.add_optional_clientscope(clientscope['id'], realm, client_id)
|
||||
|
||||
result["changed"] = (
|
||||
len(default_clientscopes_add) > 0
|
||||
or len(optional_clientscopes_add) > 0
|
||||
or len(default_clientscopes_delete) > 0
|
||||
or len(optional_clientscopes_delete) > 0
|
||||
)
|
||||
|
||||
result['end_state'].update({
|
||||
'default_clientscopes': extract_field(kc.get_default_clientscopes(realm, client_id)),
|
||||
'optional_clientscopes': extract_field(kc.get_optional_clientscopes(realm, client_id))
|
||||
|
|
Loading…
Reference in New Issue