Skip to content

Commit

Permalink
Fix an issue where manual user removing requires terraform state rm. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rayvorn authored Jul 15, 2021
1 parent 80112bb commit 4adaea3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion bitbucket/resource_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package bitbucket
import (
"fmt"
"github.com/hashicorp/terraform/helper/schema"
"log"
"net/url"
)

Expand Down Expand Up @@ -74,7 +75,9 @@ func resourceGroupRead(d *schema.ResourceData, m interface{}) error {
}
}

return fmt.Errorf("unable to find a matching group %s", groupName)
d.SetId("")
log.Printf("[WARN] Group %s not found, removing from state", groupName)
return nil
}

func resourceGroupUpdate(d *schema.ResourceData, m interface{}) error {
Expand Down
5 changes: 4 additions & 1 deletion bitbucket/resource_user_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"github.com/hashicorp/terraform/helper/schema"
"log"
"strings"
)

Expand Down Expand Up @@ -103,7 +104,9 @@ func resourceUserGroupRead(d *schema.ResourceData, m interface{}) error {
}
}

return fmt.Errorf("unable to find a matching user %s in group %s", userGroup.User, userGroup.Group)
d.SetId("")
log.Printf("[WARN] User %s in group %s not found, removing from state", userGroup.User, userGroup.Group)
return nil
}

func resourceUserGroupDelete(d *schema.ResourceData, m interface{}) error {
Expand Down

0 comments on commit 4adaea3

Please sign in to comment.