Skip to content

Commit

Permalink
GH-77 Address bug with Branch Restriction plans (#86)
Browse files Browse the repository at this point in the history
Specifically when you provision a Branch Restriction via Terraform, and then delete it via the UI, this results in plans erroring, due to Bitbucket's API returning a 404. We now look for the 404 and treat that as the resource has been deleted.
  • Loading branch information
zahiar authored Apr 2, 2022
1 parent 7486bb1 commit 87e41a1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bitbucket/resource_bitbucket_branch_restriction.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ func resourceBitbucketBranchRestrictionRead(ctx context.Context, resourceData *s
},
)
if err != nil {
// Handles a case whereby if the branch restrictions were deleted after being provisioned, Bitbucket's API
// returns a 404, so we treat that as the item having been deleted, therefore Terraform will re-provision
// if necessary.
if err.Error() == "404 Not Found" {
resourceData.SetId("")
return nil
}

return diag.FromErr(fmt.Errorf("unable to get branch restriction with error: %s", err))
}

Expand Down

0 comments on commit 87e41a1

Please sign in to comment.