Skip to content

Commit

Permalink
identity/group-alias: add api client lock
Browse files Browse the repository at this point in the history
  • Loading branch information
fairclothjm committed Feb 13, 2024
1 parent 8d2c1e4 commit d5a8e43
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions vault/resource_identity_group_alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ func identityGroupAliasCreate(d *schema.ResourceData, meta interface{}) error {

path := identityGroupAliasPath

provider.VaultMutexKV.Lock(path)
defer provider.VaultMutexKV.Unlock(path)

data := map[string]interface{}{
"name": name,
consts.FieldMountAccessor: mountAccessor,
Expand Down Expand Up @@ -87,6 +90,9 @@ func identityGroupAliasUpdate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Updating IdentityGroupAlias %q", id)
path := identityGroupAliasIDPath(id)

provider.VaultMutexKV.Lock(path)
defer provider.VaultMutexKV.Unlock(path)

resp, err := client.Logical().Read(path)
if err != nil {
return fmt.Errorf("error updating IdentityGroupAlias %q: %s", id, err)
Expand Down Expand Up @@ -128,6 +134,9 @@ func identityGroupAliasRead(d *schema.ResourceData, meta interface{}) error {

path := identityGroupAliasIDPath(id)

provider.VaultMutexKV.Lock(path)
defer provider.VaultMutexKV.Unlock(path)

log.Printf("[DEBUG] Reading IdentityGroupAlias %s from %q", id, path)
resp, err := client.Logical().Read(path)
if err != nil {
Expand Down Expand Up @@ -159,6 +168,9 @@ func identityGroupAliasDelete(d *schema.ResourceData, meta interface{}) error {

path := identityGroupAliasIDPath(id)

provider.VaultMutexKV.Lock(path)
defer provider.VaultMutexKV.Unlock(path)

log.Printf("[DEBUG] Deleting IdentityGroupAlias %q", id)
_, err := client.Logical().Delete(path)
if err != nil {
Expand Down

0 comments on commit d5a8e43

Please sign in to comment.