-
Notifications
You must be signed in to change notification settings - Fork 79
New resources: postgresql_grant & postgresql_default_privileges #53
New resources: postgresql_grant & postgresql_default_privileges #53
Conversation
dd7076f
to
1bbda4c
Compare
@cyrilgdn this is a huge PR, thank you for submitting this. I have one sizable structural change that I have a bias toward wanting to see, but want to ask you about it first. In your permissions blocks, you're using a slice of strings instead of a set of bools. I understand the desire to use the strings because these map to SQL DCL. In the work I'd done in the past, I have actually mapped these to booleans. Currently you'd use: resource "postgresql_grant" "test_rw" {
database = "%s"
role = "%s"
schema = "public"
object_type = "table"
privileges = ["SELECT", "INSERT", "UPDATE"]
} vs resource "postgresql_grant" "test_rw" {
database = "%s"
role = "%s"
schema = "public"
object_type = "table"
read = true
insert = true
update = true
delete = false
} The latter lets us easily do boolean algebra to assign or remove permissions and be explicit in making sure a permission isn't present. Also, you may have an interest in: https://github.com/sean-/postgresql-acl which I wrote once upon a time as a prerequisite for adding grant support. Thoughts? |
@sean- Actually the PR is splitted in two:
So this diff also contains the But your question is valid for both :) Currently, the resource Even if I understand the advantage that can provide the postgresql-acl lib, in this case I'm pretty sure it will not be easier to write the logic with booleans. Currently, thanks to the
For me it's explicit enough as the goal of Terraform is to describe in which state we want our resources. But maybe I'm not the most objective as the author of this code :) So I'm open to other opinions. |
@sean- So what do you think about that ? I'm now a maintainer of this repo and I really want make it evolve. There's multiple enhancements that I want/need to do on these new resources but as I don't want to stack lots of PRs, I would like to start merging those already open. Is your remark a no-go for #51 and this one ? I know you currently don't have much time for that so I'll probably ask other people to do reviews but I don't want to merge PRs against your will. Thanks ! |
@cyrilgdn, Hello, tell me please, when the release is expected? |
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.
A few comments, some may be related to lack of experience with Postgres though, so please forgive me learning in real time here.
"postgresql_database": resourcePostgreSQLDatabase(), | ||
"postgresql_extension": resourcePostgreSQLExtension(), | ||
"postgresql_schema": resourcePostgreSQLSchema(), | ||
"postgresql_role": resourcePostgreSQLRole(), |
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.
minor nit, but mind alphabetizing these?
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.
Will do that yes
if err != nil { | ||
return err | ||
} | ||
defer txn.Rollback() |
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 haven't worked much with sql
, but I'm guessing calling Rollback
after Commit
doesn't cause any issues?
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.
You're right 👍 !
I didn't see that as I don't manage the error of Rollback 🤦♂️
I'll see what I can do
1bbda4c
to
47a0e8d
Compare
9c127f8
to
62ab8f1
Compare
47a0e8d
to
80255dd
Compare
80255dd
to
e8dfd9f
Compare
e8dfd9f
to
f8e91e1
Compare
This resource allow to grant privileges on all existing tables or sequences for a specified role in a specified schema.
This resource allow to manage default privileges for tables or sequences for a specified role in a schema. # Conflicts: # postgresql/resource_postgresql_grant.go # Conflicts: # CHANGELOG.md
f8e91e1
to
7dccb18
Compare
@paultyng I updated the PR with, among others, your remarks. I disable these new resources for Postgres < 9 as it uses function and syntax which does not exist prior this version. |
@voslartomas Normally this week, I'm just trying to merge a last PR before. I'll let you now here, also you can watch the repository with the new "Releases only" mode in order to alerted. |
@cyrilgdn Perfect, thanks a lot. |
@cyrilgdn could we use |
@cyrilgdn also, found one issue, similar to: hashicorp/terraform#11452 when using this on RDS:
we need to first run `GRANT ${var.owner} to ${provider.username}" can / should this be implemented ? |
No, but it will be managed by the PR #52 that I would like to merge for the next release too (just looking for review).
Yes we have this issue too at my work. It can be implemented. |
Ah, didn't notice #52, gonna give it a shot tomorrow.
Yes, along with one concern that I have plus I might try to implement it. |
@voslartomas v0.3.0 has just been released. |
Add resources: