Skip to content

Commit 5621714

Browse files
authored
Merge branch 'main' into dependabot/go_modules/github.com/hashicorp/terraform-plugin-framework-validators-0.16.0
2 parents 62b07b4 + 71794aa commit 5621714

28 files changed

+153
-113
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
## 1.2.0 (Octover 25, 2024)
1+
## 1.2.2 (January 15, 2025)
2+
Enabled support for `cron` and `dbt_cloud` schedule strategies on Reverse ETL subscriptions.
3+
4+
## 1.2.1 (October 25, 2024)
5+
Fixes a bug where the `segment_reverse_etl_model` resource would continously update the schedule config. Also adds resource ID to error messages and upgrades some packages.
6+
7+
## 1.2.0 (October 25, 2024)
28
Moves RETL schedule config to destination_subscription and deprecates those fields in reverse_etl_model.
39

410
## 1.1.0 (August 20, 2024)

docs/resources/destination_subscription.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ resource "segment_destination_subscription" "send_to_webhook" {
8686

8787
Required:
8888

89-
- `strategy` (String) Strategy supports three modes: PERIODIC, SPECIFIC_DAYS, or MANUAL.
89+
- `strategy` (String) Strategy supports the following modes: PERIODIC, SPECIFIC_DAYS, CRON, DBT_CLOUD or MANUAL.
9090

9191
Optional:
9292

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.16.0
1212
github.com/hashicorp/terraform-plugin-go v0.25.0
1313
github.com/hashicorp/terraform-plugin-testing v1.10.0
14-
github.com/segmentio/public-api-sdk-go v0.0.0-20241025180535-501a23c07559
14+
github.com/segmentio/public-api-sdk-go v0.0.0-20250113195817-34106b6e08dd
1515
gotest.tools/gotestsum v1.12.0
1616
)
1717

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3V
187187
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
188188
github.com/segmentio/public-api-sdk-go v0.0.0-20241025180535-501a23c07559 h1:6jgXPksz5bEJUMbhp4biSIViye/Os2yfAOx9yy44e1g=
189189
github.com/segmentio/public-api-sdk-go v0.0.0-20241025180535-501a23c07559/go.mod h1:yKkoPfcOkkYjiZQj4lRWxji0Qwc6ncNEf7wCfywochY=
190+
github.com/segmentio/public-api-sdk-go v0.0.0-20250113195817-34106b6e08dd h1:slroHJmwguMVr+wLnpigxN+51E6rkeoSsdp0f2YdmTI=
191+
github.com/segmentio/public-api-sdk-go v0.0.0-20250113195817-34106b6e08dd/go.mod h1:rtbFvYN1VVsfSc55BtGTC45YwkcrbOgCwTqZwlauBh0=
190192
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
191193
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
192194
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
@@ -204,6 +206,7 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
204206
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
205207
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
206208
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
209+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
207210
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
208211
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
209212
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=

internal/provider/destination_data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (d *destinationDataSource) Read(ctx context.Context, req datasource.ReadReq
8181
}
8282
if err != nil {
8383
resp.Diagnostics.AddError(
84-
"Unable to read Destination",
84+
fmt.Sprintf("Unable to read Destination (ID: %s)", state.ID.ValueString()),
8585
getError(err, body),
8686
)
8787

internal/provider/destination_filter_resource.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (r *destinationFilterResource) Read(ctx context.Context, req resource.ReadR
202202
}
203203
if err != nil {
204204
resp.Diagnostics.AddError(
205-
"Unable to read Destination Filter",
205+
fmt.Sprintf("Unable to read Destination Filter (ID: %s)", previousState.ID.ValueString()),
206206
getError(err, body),
207207
)
208208

@@ -271,7 +271,7 @@ func (r *destinationFilterResource) Update(ctx context.Context, req resource.Upd
271271
}
272272
if err != nil {
273273
resp.Diagnostics.AddError(
274-
"Unable to update Destination Filter",
274+
fmt.Sprintf("Unable to update Destination Filter (ID: %s)", state.ID.ValueString()),
275275
getError(err, body),
276276
)
277277

@@ -314,7 +314,7 @@ func (r *destinationFilterResource) Delete(ctx context.Context, req resource.Del
314314
}
315315
if err != nil {
316316
resp.Diagnostics.AddError(
317-
"Unable to delete Destination Filter",
317+
fmt.Sprintf("Unable to delete Destination Filter (ID: %s)", state.ID.ValueString()),
318318
getError(err, body),
319319
)
320320

internal/provider/destination_metadata_data_source.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ func (d *destinationMetadataDataSource) Read(ctx context.Context, req datasource
401401
}
402402
if err != nil {
403403
resp.Diagnostics.AddError(
404-
"Unable to read Source metadata",
404+
fmt.Sprintf("Unable to read Source metadata (ID: %s)", state.ID.ValueString()),
405405
getError(err, body),
406406
)
407407

@@ -412,7 +412,7 @@ func (d *destinationMetadataDataSource) Read(ctx context.Context, req datasource
412412
err = state.Fill(destinationMetadata)
413413
if err != nil {
414414
resp.Diagnostics.AddError(
415-
"Unable to read Source metadata",
415+
fmt.Sprintf("Unable to read Source metadata (ID: %s)", state.ID.ValueString()),
416416
err.Error(),
417417
)
418418

internal/provider/destination_resource.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ func (r *destinationResource) Read(ctx context.Context, req resource.ReadRequest
588588
}
589589
if err != nil {
590590
resp.Diagnostics.AddError(
591-
"Unable to read Destination",
591+
fmt.Sprintf("Unable to read Destination (ID: %s)", previousState.ID.ValueString()),
592592
getError(err, body),
593593
)
594594

@@ -650,7 +650,7 @@ func (r *destinationResource) Update(ctx context.Context, req resource.UpdateReq
650650
}
651651
if err != nil {
652652
resp.Diagnostics.AddError(
653-
"Unable to update Destination",
653+
fmt.Sprintf("Unable to update Destination (ID: %s)", plan.ID.ValueString()),
654654
getError(err, body),
655655
)
656656

@@ -695,7 +695,7 @@ func (r *destinationResource) Delete(ctx context.Context, req resource.DeleteReq
695695
}
696696
if err != nil {
697697
resp.Diagnostics.AddError(
698-
"Unable to delete Destination",
698+
fmt.Sprintf("Unable to delete Destination (ID: %s)", state.ID.ValueString()),
699699
getError(err, body),
700700
)
701701

internal/provider/destination_subscription_resource.go

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (r *destinationSubscriptionResource) Schema(_ context.Context, _ resource.S
100100
Attributes: map[string]schema.Attribute{
101101
"strategy": schema.StringAttribute{
102102
Required: true,
103-
Description: "Strategy supports three modes: PERIODIC, SPECIFIC_DAYS, or MANUAL.",
103+
Description: "Strategy supports the following modes: PERIODIC, SPECIFIC_DAYS, CRON, DBT_CLOUD or MANUAL.",
104104
},
105105
"config": schema.StringAttribute{
106106
Optional: true,
@@ -182,7 +182,7 @@ func (r *destinationSubscriptionResource) Create(ctx context.Context, req resour
182182
}
183183
if err != nil {
184184
resp.Diagnostics.AddError(
185-
"Unable to update Destination subscription",
185+
fmt.Sprintf("Unable to update Destination subscription (ID: %s)", plan.ID.ValueString()),
186186
getError(err, body),
187187
)
188188

@@ -229,7 +229,7 @@ func (r *destinationSubscriptionResource) Read(ctx context.Context, req resource
229229
}
230230
if err != nil {
231231
resp.Diagnostics.AddError(
232-
"Unable to read Destination subscription",
232+
fmt.Sprintf("Unable to read Destination subscription (ID: %s)", previousState.ID.ValueString()),
233233
getError(err, body),
234234
)
235235

@@ -312,7 +312,7 @@ func (r *destinationSubscriptionResource) Update(ctx context.Context, req resour
312312
}
313313
if err != nil {
314314
resp.Diagnostics.AddError(
315-
"Unable to update Destination subscription",
315+
fmt.Sprintf("Unable to update Destination subscription (ID: %s)", plan.ID.ValueString()),
316316
getError(err, body),
317317
)
318318

@@ -353,7 +353,7 @@ func (r *destinationSubscriptionResource) Delete(ctx context.Context, req resour
353353
}
354354
if err != nil {
355355
resp.Diagnostics.AddError(
356-
"Unable to delete Destination subscription",
356+
fmt.Sprintf("Unable to delete Destination subscription (ID: %s)", config.ID.ValueString()),
357357
getError(err, body),
358358
)
359359

@@ -494,6 +494,58 @@ func getSchedule(ctx context.Context, planSchedule basetypes.ObjectValue) (*api.
494494
"Manual reverse ETL schedule strategy does not require a config",
495495
)
496496
reverseETLSchedule.Config = *api.NewNullableConfig(nil)
497+
} else if reverseETLSchedule.Strategy == "CRON" {
498+
reverseETLModelScheduleConfig := api.ReverseEtlCronScheduleConfig{}
499+
var config string
500+
err = wrappedReverseETLModelScheduleConfig.As(&config)
501+
if err != nil {
502+
diags.AddError(
503+
"Unable to decode reverse ETL schedule config",
504+
err.Error(),
505+
)
506+
507+
return nil, diags
508+
}
509+
510+
err = json.Unmarshal([]byte(config), &reverseETLModelScheduleConfig)
511+
if err != nil {
512+
diags.AddError(
513+
"Unable to decode reverse ETL schedule config",
514+
err.Error(),
515+
)
516+
517+
return nil, diags
518+
}
519+
520+
reverseETLSchedule.Config = *api.NewNullableConfig(&api.Config{
521+
ReverseEtlCronScheduleConfig: &reverseETLModelScheduleConfig,
522+
})
523+
} else if reverseETLSchedule.Strategy == "DBT_CLOUD" {
524+
reverseETLModelScheduleConfig := api.ReverseEtlDbtCloudScheduleConfig{}
525+
var config string
526+
err = wrappedReverseETLModelScheduleConfig.As(&config)
527+
if err != nil {
528+
diags.AddError(
529+
"Unable to decode reverse ETL schedule config",
530+
err.Error(),
531+
)
532+
533+
return nil, diags
534+
}
535+
536+
err = json.Unmarshal([]byte(config), &reverseETLModelScheduleConfig)
537+
if err != nil {
538+
diags.AddError(
539+
"Unable to decode reverse ETL schedule config",
540+
err.Error(),
541+
)
542+
543+
return nil, diags
544+
}
545+
546+
reverseETLSchedule.Config = *api.NewNullableConfig(&api.Config{
547+
ReverseEtlDbtCloudScheduleConfig: &reverseETLModelScheduleConfig,
548+
})
497549
} else {
498550
diags.AddError(
499551
"Unsupported reverse ETL schedule strategy",

internal/provider/function_resource.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func (r *functionResource) Read(ctx context.Context, req resource.ReadRequest, r
190190
}
191191
if err != nil {
192192
resp.Diagnostics.AddError(
193-
"Unable to read Function",
193+
fmt.Sprintf("Unable to read Function (ID: %s)", previousState.ID.ValueString()),
194194
getError(err, body),
195195
)
196196

@@ -247,7 +247,7 @@ func (r *functionResource) Update(ctx context.Context, req resource.UpdateReques
247247
}
248248
if err != nil {
249249
resp.Diagnostics.AddError(
250-
"Unable to update Function",
250+
fmt.Sprintf("Unable to update Function (ID: %s)", plan.ID.ValueString()),
251251
getError(err, body),
252252
)
253253

@@ -284,7 +284,7 @@ func (r *functionResource) Delete(ctx context.Context, req resource.DeleteReques
284284
}
285285
if err != nil {
286286
resp.Diagnostics.AddError(
287-
"Unable to delete Function",
287+
fmt.Sprintf("Unable to delete Function (ID: %s)", config.ID.ValueString()),
288288
getError(err, body),
289289
)
290290

0 commit comments

Comments
 (0)