Skip to content
This repository has been archived by the owner on Nov 14, 2020. It is now read-only.

Commit

Permalink
[resource_postgresql_default_privileges] add support for types and fu…
Browse files Browse the repository at this point in the history
…nctions default privileges
  • Loading branch information
Vince-Chenal committed Jun 22, 2020
1 parent 7d6a284 commit dfcd06c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions postgresql/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ var allowedPrivileges = map[string][]string{
"table": []string{"ALL", "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER"},
"sequence": []string{"ALL", "USAGE", "SELECT", "UPDATE"},
"function": []string{"ALL", "EXECUTE"},
"type": []string{"ALL", "USAGE"},
}

// validatePrivileges checks that privileges to apply are allowed for this object type.
Expand Down
4 changes: 4 additions & 0 deletions postgresql/resource_postgresql_default_privileges.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ func resourcePostgreSQLDefaultPrivileges() *schema.Resource {
"function",
}, false),
Description: "The PostgreSQL object type to set the default privileges on (one of: table, sequence, function)",
"type",
"function",
}, false),
Description: "The PostgreSQL object type to set the default privileges on (one of: table, sequence, function, type)",
},
"privileges": &schema.Schema{
Type: schema.TypeSet,
Expand Down
1 change: 1 addition & 0 deletions postgresql/resource_postgresql_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var objectTypes = map[string]string{
"table": "r",
"sequence": "S",
"function": "f",
"type": "T",
}

func resourcePostgreSQLGrant() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/postgresql_default_privileges.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ resource "postgresql_default_privileges" "read_only_tables" {
* `database` - (Required) The database to grant default privileges for this role.
* `owner` - (Required) Role for which apply default privileges (You can change default privileges only for objects that will be created by yourself or by roles that you are a member of).
* `schema` - (Required) The database schema to set default privileges for this role.
* `object_type` - (Required) The PostgreSQL object type to set the default privileges on (one of: table, sequence,function).
* `object_type` - (Required) The PostgreSQL object type to set the default privileges on (one of: table, sequence, function, type).
* `privileges` - (Required) The list of privileges to apply as default privileges.

0 comments on commit dfcd06c

Please sign in to comment.