mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-03 08:42:39 +00:00
use same mutex for project_iam_policy as the other project_iam resources (#1645)
This commit is contained in:
parent
d4b4436feb
commit
0497eec580
|
@ -2,6 +2,7 @@ package google
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/errwrap"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"google.golang.org/api/cloudresourcemanager/v1"
|
||||
|
@ -65,7 +66,7 @@ func (u *ProjectIamUpdater) GetResourceId() string {
|
|||
}
|
||||
|
||||
func (u *ProjectIamUpdater) GetMutexKey() string {
|
||||
return fmt.Sprintf("iam-project-%s", u.resourceId)
|
||||
return getProjectIamPolicyMutexKey(u.resourceId)
|
||||
}
|
||||
|
||||
func (u *ProjectIamUpdater) DescribeResource() string {
|
||||
|
|
|
@ -61,6 +61,11 @@ func resourceGoogleProjectIamPolicyCreate(d *schema.ResourceData, meta interface
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mutexKey := getProjectIamPolicyMutexKey(pid)
|
||||
mutexKV.Lock(mutexKey)
|
||||
defer mutexKV.Unlock(mutexKey)
|
||||
|
||||
// Get the policy in the template
|
||||
p, err := getResourceIamPolicy(d)
|
||||
if err != nil {
|
||||
|
@ -153,6 +158,10 @@ func resourceGoogleProjectIamPolicyUpdate(d *schema.ResourceData, meta interface
|
|||
return err
|
||||
}
|
||||
|
||||
mutexKey := getProjectIamPolicyMutexKey(pid)
|
||||
mutexKV.Lock(mutexKey)
|
||||
defer mutexKV.Unlock(mutexKey)
|
||||
|
||||
// Get the policy in the template
|
||||
p, err := getResourceIamPolicy(d)
|
||||
if err != nil {
|
||||
|
@ -220,6 +229,10 @@ func resourceGoogleProjectIamPolicyDelete(d *schema.ResourceData, meta interface
|
|||
return err
|
||||
}
|
||||
|
||||
mutexKey := getProjectIamPolicyMutexKey(pid)
|
||||
mutexKV.Lock(mutexKey)
|
||||
defer mutexKV.Unlock(mutexKey)
|
||||
|
||||
// Get the existing IAM policy from the API
|
||||
ep, err := getProjectIamPolicy(pid, config)
|
||||
if err != nil {
|
||||
|
@ -400,3 +413,7 @@ func (b sortableBindings) Swap(i, j int) {
|
|||
func (b sortableBindings) Less(i, j int) bool {
|
||||
return b[i].Role < b[j].Role
|
||||
}
|
||||
|
||||
func getProjectIamPolicyMutexKey(pid string) string {
|
||||
return fmt.Sprintf("iam-project-%s", pid)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user