-
Notifications
You must be signed in to change notification settings - Fork 1
Add new configuration and support for roles #44
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
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.
Pull request overview
This PR adds support for roles with different creation types, replacing the simple db_users list with a more structured roles configuration. The implementation distinguishes between roles created by migrations, externally managed roles, and temporary roles used during migration generation.
- Introduced three role creation types:
migration(created by SQL DDL),external(managed by operators), andtemporary(for intermediate migration compatibility) - Refactored configuration structure from
db_userslist toroleswith name and creation type properties - Renamed internal types for clarity:
Database→Instance, packageinternal→configuration
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/stages/06-roles.trek.yaml | Adds test configuration demonstrating all three role creation types |
| tests/stages/06-roles.dbm | Adds test DBM file with roles configured for sql-disabled based on creation type |
| tests/run.sh | Updates test script to support per-stage trek.yaml overrides and renames TREK_DATABASE_USERS to TREK_ROLES |
| tests/output/trek.yaml | Updates output showing new roles structure with creation types |
| tests/output/santas_warehouse.sql | Adds CREATE ROLE statement for migration-created role |
| tests/output/santas_warehouse.dbm | Adds role definitions with appropriate sql-disabled settings |
| tests/output/migrations/007_roles.up.sql | Empty migration file for roles test stage |
| internal/templates/trek.yaml.tmpl | Updates template to generate roles with creation type instead of simple user list |
| internal/templates/dbm.tmpl | Updates to use roleNames instead of db_users |
| internal/templates.go | Changes parameter type to configuration.Template and uses 'any' instead of 'interface{}' |
| internal/postgres/embedded.go | Renames type from postgresDatabaseEmbedded to postgresInstanceEmbedded |
| internal/postgres/common.go | Renames Database interface to Instance, function names, and removes CreateUsers function |
| internal/dbm/dbm.go | Refactors inline structs to named Role and Database types |
| internal/configuration/config.go | Moves from internal package, adds Role type with creation field and validation logic |
| cmd/init.go | Updates to use configuration package, renames database-users flag to roles |
| cmd/generate.go | Implements role creation logic based on creation type and adds role statement generation |
| cmd/check.go | Updates validation to check role creation types match sql-disabled settings |
| cmd/apply.go | Implements role creation and cleanup logic for different creation types |
Comments suppressed due to low confidence (2)
internal/configuration/config.go:92
- The error message uses the full Role struct in string formatting instead of just the role name. This will produce unclear output like "Database user {name creation}" instead of "Database user 'name'". Use role.Name instead of role.
internal/configuration/config.go:102 - The error message uses the full Role struct in string formatting instead of just the role name. This will produce unclear output like "Database user {name creation}" instead of "Database user 'name'". Use role.Name instead of role.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fc7c348 to
8ecd1f2
Compare
|
Could you split it into multiple commits, so that the renamings and so on are not mixed with everything else? That would be much easier to review. |
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.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (2)
internal/configuration/config.go:78
- The error message is printing the role struct instead of the role name. This should be
role.Nameto properly display which role name contains invalid characters.
internal/configuration/config.go:77 - The error message still refers to "Database user" instead of "Role" after the refactoring. This message should be updated to match the new terminology.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8ecd1f2 to
bdac922
Compare
bdac922 to
fffff66
Compare
provokateurin
left a comment
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.
I'm not really sure about the behavior change regarding roles. I think the config checks should be dropped/changed, as we now support roles with sql-disabled=true, which must be managed externally?
fffff66 to
acd3294
Compare
acd3294 to
fffff66
Compare
No description provided.