Skip to content

Commit 0f352cd

Browse files
authored
Ensure created resources are tainted properly upon failed applies (#99)
1 parent df304cc commit 0f352cd

12 files changed

+26
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.10.3 (March 6, 2024)
2+
Correctly taints resources upon failed create to ensure resources are not duplicated.
3+
14
## 0.10.2 (March 6, 2024)
25
Fixes a rendering bug for `segment_profiles_warehouse` resource docs.
36

internal/provider/destination_filter_resource.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ func (r *destinationFilterResource) Create(ctx context.Context, req resource.Cre
166166
}
167167

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

170172
var state models.DestinationFilterState
171173
err = state.Fill(&destinationfilter)

internal/provider/destination_resource.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ func (r *destinationResource) Create(ctx context.Context, req resource.CreateReq
549549

550550
return
551551
}
552+
resp.State.SetAttribute(ctx, path.Root("id"), out.Data.Destination.Id)
552553

553554
var state models.DestinationState
554555
err = state.Fill(&out.Data.Destination)

internal/provider/destination_subscription_resource.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ func (r *destinationSubscriptionResource) Create(ctx context.Context, req resour
132132

133133
destinationSubscription := out.Data.GetDestinationSubscription()
134134

135+
resp.State.SetAttribute(ctx, path.Root("id"), destinationSubscription.Id)
136+
135137
var state models.DestinationSubscriptionState
136138
err = state.Fill(destinationSubscription)
137139
if err != nil {

internal/provider/function_resource.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ func (r *functionResource) Create(ctx context.Context, req resource.CreateReques
156156

157157
function := out.Data.GetFunction()
158158

159+
resp.State.SetAttribute(ctx, path.Root("id"), function.Id)
160+
159161
var state models.FunctionState
160162
state.Fill(api.Function(function))
161163

internal/provider/insert_function_instance_resource.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ func (r *insertFunctionInstanceResource) Create(ctx context.Context, req resourc
117117

118118
insertFunctionInstance := out.Data.InsertFunctionInstance
119119

120+
resp.State.SetAttribute(ctx, path.Root("id"), insertFunctionInstance.Id)
121+
120122
var state models.InsertFunctionInstanceState
121123
err = state.Fill(insertFunctionInstance)
122124
if err != nil {

internal/provider/profiles_warehouse_resource.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ func (r *profilesWarehouseResource) Create(ctx context.Context, req resource.Cre
130130

131131
profilesWarehouse := out.Data.GetProfilesWarehouse()
132132

133+
resp.State.SetAttribute(ctx, path.Root("id"), profilesWarehouse.Id)
134+
resp.State.SetAttribute(ctx, path.Root("space_id"), plan.SpaceID.ValueString())
135+
133136
var state models.ProfilesWarehouseState
134137
err = state.Fill(profilesWarehouse)
135138
if err != nil {

internal/provider/reverse_etl_model_resource.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ func (r *reverseETLModelResource) Create(ctx context.Context, req resource.Creat
127127

128128
reverseETLModel := out.Data.ReverseEtlModel
129129

130+
resp.State.SetAttribute(ctx, path.Root("id"), reverseETLModel.Id)
131+
130132
var state models.ReverseETLModelState
131133
err = state.Fill(reverseETLModel)
132134
if err != nil {

internal/provider/tracking_plan_resource.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ func (r *trackingPlanResource) Create(ctx context.Context, req resource.CreateRe
148148

149149
trackingPlan := out.Data.GetTrackingPlan()
150150

151+
resp.State.SetAttribute(ctx, path.Root("id"), trackingPlan.Id)
152+
151153
var rules []models.RulesState
152154
plan.Rules.ElementsAs(ctx, &rules, false)
153155

internal/provider/transformation_resource.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ func (r *transformationResource) Create(ctx context.Context, req resource.Create
178178

179179
transformation := out.Data.GetTransformation()
180180

181+
resp.State.SetAttribute(ctx, path.Root("id"), transformation.Id)
182+
181183
var state models.TransformationState
182184
state.Fill(transformation)
183185

0 commit comments

Comments
 (0)