-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
keycloak_client: remove code that turns attributes dict into list #9077
keycloak_client: remove code that turns attributes dict into list #9077
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
changelogs/fragments/9077-keycloak_client-fix-attributes-dict-turned-into-list.yml
Outdated
Show resolved
Hide resolved
@@ -805,9 +805,6 @@ def normalise_cr(clientrep, remove_ids=False): | |||
# Avoid the dict passed in to be modified | |||
clientrep = clientrep.copy() | |||
|
|||
if 'attributes' in clientrep: | |||
clientrep['attributes'] = list(sorted(clientrep['attributes'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that this used to be a list, and was changed to a dict at some point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It kinda looks like it. But i checked Keycloak 5, 9, 13, 18, 25 and its always a dict. Same for the clientscopes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…turned-into-list.yml Co-authored-by: Felix Fontein <felix@fontein.de>
Hey Felix,
I added it because when I ran ansible in check mode, I found that
sometimes (possibly after a keycloak restart) the order of attribute didn't
match between desired and what keycloak returned. Thus a false difference
is reported because the order of attributes doesn't matter I chose to add
the sorting there before determining if there is a difference.
I think I have might have more changes like this in my personal fork
because my use case was to deploy every few weeks, and only proceed if the
check passed when running the previous ansible code before the new ansible
code.
Note : answering in my phone without looking at the full diff.
…On Wed, 6 Nov 2024, 5:43 am Felix Fontein, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In plugins/modules/keycloak_client.py
<#9077 (comment)>
:
> @@ -805,9 +805,6 @@ def normalise_cr(clientrep, remove_ids=False):
# Avoid the dict passed in to be modified
clientrep = clientrep.copy()
- if 'attributes' in clientrep:
- clientrep['attributes'] = list(sorted(clientrep['attributes']))
This was added in #3610
<#3610> by
@pmdumuid <https://github.com/pmdumuid>. @pmdumuid
<https://github.com/pmdumuid> do you remember why you chose this? The
tests added in the PR use Keycloak 12.0.4, maybe that version uses it for
whatever reason (even if 9 and 13 do not)?
—
Reply to this email directly, view it on GitHub
<#9077 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AASCFVVU4IKSQO7NGO4MJSLZ7EKFBAVCNFSM6AAAAABQZ7VC7SVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDIMJWGQ4DOMZXGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Sorry I have just reread what I responded wirh after sending it. Please
replace
"I chose to"
with
". I avoided this false difference in check mode by choosing to "
…On Wed, 6 Nov 2024, 9:09 am Pierre Dumuid, ***@***.***> wrote:
Hey Felix,
I added it because when I ran ansible in check mode, I found that
sometimes (possibly after a keycloak restart) the order of attribute didn't
match between desired and what keycloak returned. Thus a false difference
is reported because the order of attributes doesn't matter I chose to add
the sorting there before determining if there is a difference.
I think I have might have more changes like this in my personal fork
because my use case was to deploy every few weeks, and only proceed if the
check passed when running the previous ansible code before the new ansible
code.
Note : answering in my phone without looking at the full diff.
On Wed, 6 Nov 2024, 5:43 am Felix Fontein, ***@***.***>
wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In plugins/modules/keycloak_client.py
> <#9077 (comment)>
> :
>
> > @@ -805,9 +805,6 @@ def normalise_cr(clientrep, remove_ids=False):
> # Avoid the dict passed in to be modified
> clientrep = clientrep.copy()
>
> - if 'attributes' in clientrep:
> - clientrep['attributes'] = list(sorted(clientrep['attributes']))
>
> This was added in #3610
> <#3610> by
> @pmdumuid <https://github.com/pmdumuid>. @pmdumuid
> <https://github.com/pmdumuid> do you remember why you chose this? The
> tests added in the PR use Keycloak 12.0.4, maybe that version uses it for
> whatever reason (even if 9 and 13 do not)?
>
> —
> Reply to this email directly, view it on GitHub
> <#9077 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AASCFVVU4IKSQO7NGO4MJSLZ7EKFBAVCNFSM6AAAAABQZ7VC7SVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDIMJWGQ4DOMZXGA>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***
> .com>
>
|
I checked 12.0.4 but its also a dict. @pmdumuid |
Backport to stable-9: 💚 backport PR created✅ Backport PR branch: Backported as #9115 🤖 @patchback |
) * remove code that turns attributes dict into list * add changelog fragment * Update changelogs/fragments/9077-keycloak_client-fix-attributes-dict-turned-into-list.yml Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit 62cb608)
Backport to stable-10: 💚 backport PR created✅ Backport PR branch: Backported as #9116 🤖 @patchback |
) * remove code that turns attributes dict into list * add changelog fragment * Update changelogs/fragments/9077-keycloak_client-fix-attributes-dict-turned-into-list.yml Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit 62cb608)
I decided to merge this since currently it seems that the PR is correct, and so that it can go into the 10.0.1 release. Thanks everyone! |
…that turns attributes dict into list (#9116) keycloak_client: remove code that turns attributes dict into list (#9077) * remove code that turns attributes dict into list * add changelog fragment * Update changelogs/fragments/9077-keycloak_client-fix-attributes-dict-turned-into-list.yml Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit 62cb608) Co-authored-by: fgruenbauer <gruenbauer@b1-systems.de>
…hat turns attributes dict into list (#9115) keycloak_client: remove code that turns attributes dict into list (#9077) * remove code that turns attributes dict into list * add changelog fragment * Update changelogs/fragments/9077-keycloak_client-fix-attributes-dict-turned-into-list.yml Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit 62cb608) Co-authored-by: fgruenbauer <gruenbauer@b1-systems.de>
…sible-collections#9077) * remove code that turns attributes dict into list * add changelog fragment * Update changelogs/fragments/9077-keycloak_client-fix-attributes-dict-turned-into-list.yml Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de>
SUMMARY
The
attribute
config item contains a dict with additional settings. The module turns the dict into a list before storing it for the diff/end_state, which turns it into a list of just the keys:The actual data sent to the API is not changed, so only
--diff
/end_state
is affected.ISSUE TYPE
COMPONENT NAME
keycloak_client
ADDITIONAL INFORMATION
Create a client with the module with any of the
attributes
settings from above set and--diff
.