Skip to content

Commit

Permalink
Ensure created resources are tainted properly upon failed applies (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
deanhuynh authored Mar 6, 2024
1 parent df304cc commit 0f352cd
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.10.3 (March 6, 2024)
Correctly taints resources upon failed create to ensure resources are not duplicated.

## 0.10.2 (March 6, 2024)
Fixes a rendering bug for `segment_profiles_warehouse` resource docs.

Expand Down
2 changes: 2 additions & 0 deletions internal/provider/destination_filter_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ func (r *destinationFilterResource) Create(ctx context.Context, req resource.Cre
}

destinationfilter := out.Data.Filter
resp.State.SetAttribute(ctx, path.Root("id"), destinationfilter.Id)
resp.State.SetAttribute(ctx, path.Root("destination_id"), destinationfilter.DestinationId)

var state models.DestinationFilterState
err = state.Fill(&destinationfilter)
Expand Down
1 change: 1 addition & 0 deletions internal/provider/destination_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ func (r *destinationResource) Create(ctx context.Context, req resource.CreateReq

return
}
resp.State.SetAttribute(ctx, path.Root("id"), out.Data.Destination.Id)

var state models.DestinationState
err = state.Fill(&out.Data.Destination)
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/destination_subscription_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ func (r *destinationSubscriptionResource) Create(ctx context.Context, req resour

destinationSubscription := out.Data.GetDestinationSubscription()

resp.State.SetAttribute(ctx, path.Root("id"), destinationSubscription.Id)

var state models.DestinationSubscriptionState
err = state.Fill(destinationSubscription)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/function_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ func (r *functionResource) Create(ctx context.Context, req resource.CreateReques

function := out.Data.GetFunction()

resp.State.SetAttribute(ctx, path.Root("id"), function.Id)

var state models.FunctionState
state.Fill(api.Function(function))

Expand Down
2 changes: 2 additions & 0 deletions internal/provider/insert_function_instance_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ func (r *insertFunctionInstanceResource) Create(ctx context.Context, req resourc

insertFunctionInstance := out.Data.InsertFunctionInstance

resp.State.SetAttribute(ctx, path.Root("id"), insertFunctionInstance.Id)

var state models.InsertFunctionInstanceState
err = state.Fill(insertFunctionInstance)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions internal/provider/profiles_warehouse_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ func (r *profilesWarehouseResource) Create(ctx context.Context, req resource.Cre

profilesWarehouse := out.Data.GetProfilesWarehouse()

resp.State.SetAttribute(ctx, path.Root("id"), profilesWarehouse.Id)
resp.State.SetAttribute(ctx, path.Root("space_id"), plan.SpaceID.ValueString())

var state models.ProfilesWarehouseState
err = state.Fill(profilesWarehouse)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/reverse_etl_model_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ func (r *reverseETLModelResource) Create(ctx context.Context, req resource.Creat

reverseETLModel := out.Data.ReverseEtlModel

resp.State.SetAttribute(ctx, path.Root("id"), reverseETLModel.Id)

var state models.ReverseETLModelState
err = state.Fill(reverseETLModel)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/tracking_plan_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ func (r *trackingPlanResource) Create(ctx context.Context, req resource.CreateRe

trackingPlan := out.Data.GetTrackingPlan()

resp.State.SetAttribute(ctx, path.Root("id"), trackingPlan.Id)

var rules []models.RulesState
plan.Rules.ElementsAs(ctx, &rules, false)

Expand Down
2 changes: 2 additions & 0 deletions internal/provider/transformation_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ func (r *transformationResource) Create(ctx context.Context, req resource.Create

transformation := out.Data.GetTransformation()

resp.State.SetAttribute(ctx, path.Root("id"), transformation.Id)

var state models.TransformationState
state.Fill(transformation)

Expand Down
3 changes: 3 additions & 0 deletions internal/provider/user_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ func (r *userResource) Create(ctx context.Context, req resource.CreateRequest, r
return
}

resp.State.SetAttribute(ctx, path.Root("id"), plan.Email.ValueString())
resp.State.SetAttribute(ctx, path.Root("is_invite"), true)

user, err := findUser(r.authContext, r.client, plan.Email.ValueString())
if err != nil {
resp.Diagnostics.AddError(
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/warehouse_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ func (r *warehouseResource) Create(ctx context.Context, req resource.CreateReque

warehouse := out.Data.GetWarehouse()

resp.State.SetAttribute(ctx, path.Root("id"), warehouse.Id)

var state models.WarehouseState
err = state.Fill(warehouse)
if err != nil {
Expand Down

0 comments on commit 0f352cd

Please sign in to comment.