Skip to content

Commit

Permalink
make use of remove resource method for marking resource as destroyed
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinBettati committed Aug 16, 2023
1 parent 2f919ef commit 65765ab
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions mongodbatlas/fw_resource_mongodbatlas_alert_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ import (
)

const (
errorCreateAlertConf = "error creating Alert Configuration information: %s"
errorReadAlertConf = "error getting Alert Configuration information: %s"
errorUpdateAlertConf = "error updating Alert Configuration information: %s"
errorAlertConfSetting = "error setting `%s` for Alert Configuration (%s): %s"
pagerDuty = "PAGER_DUTY"
opsGenie = "OPS_GENIE"
victorOps = "VICTOR_OPS"
encodedIDKeyAlertID = "id"
encodedIDKeyProjectID = "project_id"
alertConfigurationResourceName = "alert_configuration"
errorCreateAlertConf = "error creating Alert Configuration information: %s"
errorReadAlertConf = "error getting Alert Configuration information: %s"
errorUpdateAlertConf = "error updating Alert Configuration information: %s"
errorAlertConfSetting = "error setting `%s` for Alert Configuration (%s): %s"
pagerDuty = "PAGER_DUTY"
opsGenie = "OPS_GENIE"
victorOps = "VICTOR_OPS"
encodedIDKeyAlertID = "id"
encodedIDKeyProjectID = "project_id"
)

var _ resource.Resource = &AlertConfigurationRS{}
Expand Down Expand Up @@ -105,7 +106,7 @@ type tfNotificationModel struct {
}

func (r *AlertConfigurationRS) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_alert_configuration"
resp.TypeName = fmt.Sprintf("%s_%s", req.ProviderTypeName, alertConfigurationResourceName)
}

func (r *AlertConfigurationRS) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
Expand Down Expand Up @@ -404,8 +405,7 @@ func (r *AlertConfigurationRS) Read(ctx context.Context, req resource.ReadReques
if err != nil {
// deleted in the backend case
if getResp != nil && getResp.StatusCode == http.StatusNotFound {
alertConfigState.ID = types.StringValue("") // TODO verify this works
resp.Diagnostics.Append(resp.State.Set(ctx, alertConfigState)...)
resp.State.RemoveResource(ctx)
return
}
resp.Diagnostics.AddError(errorReadAlertConf, err.Error())
Expand Down

0 comments on commit 65765ab

Please sign in to comment.