Fix an issue where manual user removing requires terraform state rm. (#35)

This commit is contained in:
rayvorn
2021-07-14 20:06:54 -04:00
committed by GitHub
parent 80112bb5a9
commit 4adaea3109
2 changed files with 8 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ package bitbucket
import ( import (
"fmt" "fmt"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
"log"
"net/url" "net/url"
) )
@@ -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 { func resourceGroupUpdate(d *schema.ResourceData, m interface{}) error {

View File

@@ -5,6 +5,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
"log"
"strings" "strings"
) )
@@ -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 { func resourceUserGroupDelete(d *schema.ResourceData, m interface{}) error {