Skip to content

Commit a9bab3e

Browse files
committed
Deprecate schedule in reverse etl model resource
1 parent 14868be commit a9bab3e

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0
1212
github.com/hashicorp/terraform-plugin-go v0.24.0
1313
github.com/hashicorp/terraform-plugin-testing v1.10.0
14-
github.com/segmentio/public-api-sdk-go v0.0.0-20241017001201-fbbdab459db8
14+
github.com/segmentio/public-api-sdk-go v0.0.0-20241025180535-501a23c07559
1515
gotest.tools/gotestsum v1.12.0
1616
)
1717

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ github.com/segmentio/public-api-sdk-go v0.0.0-20240909200753-311bb8d791a2 h1:vlK
189189
github.com/segmentio/public-api-sdk-go v0.0.0-20240909200753-311bb8d791a2/go.mod h1:yKkoPfcOkkYjiZQj4lRWxji0Qwc6ncNEf7wCfywochY=
190190
github.com/segmentio/public-api-sdk-go v0.0.0-20241017001201-fbbdab459db8 h1:pYJu97HA0FVdy+WCqQbS/baDzXxg2q0Vl+akD6SUBSI=
191191
github.com/segmentio/public-api-sdk-go v0.0.0-20241017001201-fbbdab459db8/go.mod h1:yKkoPfcOkkYjiZQj4lRWxji0Qwc6ncNEf7wCfywochY=
192+
github.com/segmentio/public-api-sdk-go v0.0.0-20241025180535-501a23c07559 h1:6jgXPksz5bEJUMbhp4biSIViye/Os2yfAOx9yy44e1g=
193+
github.com/segmentio/public-api-sdk-go v0.0.0-20241025180535-501a23c07559/go.mod h1:yKkoPfcOkkYjiZQj4lRWxji0Qwc6ncNEf7wCfywochY=
192194
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
193195
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
194196
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=

internal/provider/reverse_etl_model_resource.go

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,13 @@ func (r *reverseETLModelResource) Create(ctx context.Context, req resource.Creat
9898
return
9999
}
100100

101-
var scheduleConfig map[string]interface{}
102-
if !plan.ScheduleConfig.IsNull() && !plan.ScheduleConfig.IsUnknown() {
103-
diags = plan.ScheduleConfig.Unmarshal(&scheduleConfig)
104-
resp.Diagnostics.Append(diags...)
105-
if resp.Diagnostics.HasError() {
106-
return
107-
}
108-
}
109-
110101
out, body, err := r.client.ReverseETLAPI.CreateReverseEtlModel(r.authContext).CreateReverseEtlModelInput(api.CreateReverseEtlModelInput{
111102
Name: plan.Name.ValueString(),
112103
SourceId: plan.SourceID.ValueString(),
113104
Description: plan.Description.ValueString(),
114105
Enabled: plan.Enabled.ValueBool(),
115-
ScheduleStrategy: plan.ScheduleStrategy.ValueString(),
116106
Query: plan.Query.ValueString(),
117107
QueryIdentifierColumn: plan.QueryIdentifierColumn.ValueString(),
118-
ScheduleConfig: scheduleConfig,
119108
}).Execute()
120109
if body != nil {
121110
defer body.Body.Close()
@@ -150,6 +139,10 @@ func (r *reverseETLModelResource) Create(ctx context.Context, req resource.Creat
150139
if resp.Diagnostics.HasError() {
151140
return
152141
}
142+
143+
// Since we deprecated these values, we just need to set them to the plan values so there are no errors
144+
resp.State.SetAttribute(ctx, path.Root("schedule_config"), plan.ScheduleConfig)
145+
resp.State.SetAttribute(ctx, path.Root("schedule_strategy"), plan.ScheduleStrategy)
153146
}
154147

155148
func (r *reverseETLModelResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
@@ -192,6 +185,14 @@ func (r *reverseETLModelResource) Read(ctx context.Context, req resource.ReadReq
192185
if resp.Diagnostics.HasError() {
193186
return
194187
}
188+
189+
// Since we deprecated these values, we just need to set them to the plan values so there are no errors
190+
if !previousState.ScheduleConfig.IsNull() && !previousState.ScheduleConfig.IsUnknown() {
191+
resp.State.SetAttribute(ctx, path.Root("schedule_config"), previousState.ScheduleConfig)
192+
}
193+
if !previousState.ScheduleStrategy.IsNull() && !previousState.ScheduleStrategy.IsUnknown() {
194+
resp.State.SetAttribute(ctx, path.Root("schedule_strategy"), previousState.ScheduleStrategy)
195+
}
195196
}
196197

197198
func (r *reverseETLModelResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
@@ -209,19 +210,10 @@ func (r *reverseETLModelResource) Update(ctx context.Context, req resource.Updat
209210
return
210211
}
211212

212-
var scheduleConfig map[string]interface{}
213-
diags = plan.ScheduleConfig.Unmarshal(&scheduleConfig)
214-
resp.Diagnostics.Append(diags...)
215-
if resp.Diagnostics.HasError() {
216-
return
217-
}
218-
219213
out, body, err := r.client.ReverseETLAPI.UpdateReverseEtlModel(r.authContext, state.ID.ValueString()).UpdateReverseEtlModelInput(api.UpdateReverseEtlModelInput{
220214
Name: plan.Name.ValueStringPointer(),
221215
Description: plan.Description.ValueStringPointer(),
222216
Enabled: plan.Enabled.ValueBoolPointer(),
223-
ScheduleStrategy: plan.ScheduleStrategy.ValueStringPointer(),
224-
ScheduleConfig: scheduleConfig,
225217
Query: plan.Query.ValueStringPointer(),
226218
QueryIdentifierColumn: plan.QueryIdentifierColumn.ValueStringPointer(),
227219
}).Execute()
@@ -252,6 +244,10 @@ func (r *reverseETLModelResource) Update(ctx context.Context, req resource.Updat
252244
if resp.Diagnostics.HasError() {
253245
return
254246
}
247+
248+
// Since we deprecated these values, we just need to set them to the plan values so there are no errors
249+
resp.State.SetAttribute(ctx, path.Root("schedule_config"), plan.ScheduleConfig)
250+
resp.State.SetAttribute(ctx, path.Root("schedule_strategy"), plan.ScheduleStrategy)
255251
}
256252

257253
func (r *reverseETLModelResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {

0 commit comments

Comments
 (0)