-
Notifications
You must be signed in to change notification settings - Fork 145
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
Provide 3 fixes for the diff plugin #726
Conversation
Will rebase after #721 is merged (I've changed the same line as in that PR) |
303f73b
to
3ddfb33
Compare
When adding or removing a user from a team you'd need to use target_team instead of team
4029df4
to
de56266
Compare
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.
Great catches! I think the else
indentation seems to be wrong. Could you check this?
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.
LGTM
Looks good to me, good additions, thanks! |
* Add instace_group info to diff plugin * Change way to compare dicts to ignore state key * Ensure that key is set to target_team in case of membership removal When adding or removing a user from a team you'd need to use target_team instead of team --------- Co-authored-by: Marges, RSY (Rick) <rick.marges@achmea.nl> Co-authored-by: Sean Sullivan <ssulliva@redhat.com>
* Add instace_group info to diff plugin * Change way to compare dicts to ignore state key * Ensure that key is set to target_team in case of membership removal When adding or removing a user from a team you'd need to use target_team instead of team --------- Co-authored-by: Marges, RSY (Rick) <rick.marges@achmea.nl> Co-authored-by: Sean Sullivan <ssulliva@redhat.com>
What does this PR do?
This PR contains 3 fixes for the diff plugin. I'll explain them one by one:
1. Usage access to instance_groups is removed:
When setting usage access to an instance_group (with
{"role": "use", "instance_groups": ["Dummy instance group"], "user": "test@example.com"}
) the diff plugin tries to remove it afterwards.This is due to the API returning information in singular version, but as can been seen above, the role module requires the plural version.
This is fixed by converting the singular versions into plural.
2. When explicitly setting
state: present
, the plugin creates a present and absent object in some casesIn some cases (I've seen it happen with organizations, but might happen with more) when someone explicitly sets
state: present
in configuration (compare_list) the diff plugin returns 2 items, one absent and one present state.This is fixed by changing the way the dicts are compared. A separate method is used where the
state
key is ignored.3. Member rights to teams aren't removed
When a user should no longer be member of a certain team the configuration is removed. However, the diff plugin creates the wrong absent dict. Setting (or removing) membership access is done by using the
target_team
key, notteam
.This is fixed by checking if the
team
key is present and therole
ismember
. If both are true, update the dict to changeteam
totarget_team
.How should this be tested?
Some items are automatically checked by the pipeline.
Otherwise tests can be performed based on the data provided in the code blocks above
Is there a relevant Issue open for this?
Other Relevant info, PRs, etc