Skip to content

Commit

Permalink
fix: Optional revoke on postgresql_grant_role
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian AYMARD authored and faymard committed Oct 3, 2024
1 parent dea1401 commit 9b5db60
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions postgresql/resource_postgresql_grant_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ func resourcePostgreSQLGrantRole() *schema.Resource {
Default: false,
Description: "Permit the grant recipient to grant it to others",
},
"revoke": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: false,
Description: "Revoke the granted roles before granting them again",
},
},
}
}
Expand Down Expand Up @@ -82,8 +89,10 @@ func resourcePostgreSQLGrantRoleCreate(db *DBConnection, d *schema.ResourceData)
defer deferredRollback(txn)

// Revoke the granted roles before granting them again.
if err = revokeRole(txn, d); err != nil {
return err
if rev, _ := d.Get("revoke").(bool); rev {
if err = revokeRole(txn, d); err != nil {
return err
}
}

if err = grantRole(txn, d); err != nil {
Expand Down

0 comments on commit 9b5db60

Please sign in to comment.