Enhance PostgreSQL role management by adding ALTER ROLE support#1318
Merged
Fizzadar merged 5 commits intopyinfra-dev:3.xfrom Apr 16, 2025
KalvadTech:postgres_update_role
Merged
Enhance PostgreSQL role management by adding ALTER ROLE support#1318Fizzadar merged 5 commits intopyinfra-dev:3.xfrom KalvadTech:postgres_update_role
Fizzadar merged 5 commits intopyinfra-dev:3.xfrom
KalvadTech:postgres_update_role
Conversation
Updated the role function to yield SQL commands for altering existing PostgreSQL roles, allowing modifications to attributes such as LOGIN, SUPERUSER, and CONNECTION LIMIT. Changed the parameter name for sudo_user to _sudo_user for consistency.
…ing role update test Deleted the role_add_noop.json file as it was no longer needed. Introduced role_update.json to test the ALTER ROLE functionality, including connection limit and password updates for the 'testuser' role.
Fizzadar
reviewed
Mar 27, 2025
Member
Fizzadar
left a comment
There was a problem hiding this comment.
Hrm, it'd be nice to not make every postgres.role operation execute a command every time, could we check the existing role to see if ALTER is needed?
I think if a password is set we'll always need to alter because we can't check those, but all the other arguments should be the relevant info on the roles fact.
Collaborator
Author
|
Correct, I will work on it |
Updated the role function to check if any attributes (LOGIN, SUPERUSER, INHERIT, CREATEDB, CREATEROLE, CONNECTION LIMIT, PASSWORD) need to be altered before executing the SQL command. Added a new test case to verify the no-op behavior when the role already exists with the specified attributes.
… function Updated the docstring in opkg.py for clarity and formatting. Enhanced type hints in the role function of postgres.py to explicitly define parameter types, improving code readability and type safety.
Collaborator
Author
|
@Fizzadar I fixed it but we need to fix the actions |
Collaborator
Author
|
@Fizzadar ready to be merged |
Fizzadar
approved these changes
Apr 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updated the role function to yield SQL commands for altering existing PostgreSQL roles, allowing modifications to attributes such as LOGIN, SUPERUSER, and CONNECTION LIMIT. Changed the parameter name for sudo_user to _sudo_user for consistency.