Skip to content

Commit 90baf2a

Browse files
authored
Merge branch 'main' into APICS-2871/retry-429
2 parents 0e8edce + f1f4434 commit 90baf2a

File tree

6 files changed

+81
-44
lines changed

6 files changed

+81
-44
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
## 1.2.1 (Octover 25, 2025)
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)
25
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.
36

4-
## 1.2.0 (Octover 25, 2024)
7+
## 1.2.0 (October 25, 2024)
58
Moves RETL schedule config to destination_subscription and deprecates those fields in reverse_etl_model.
69

710
## 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ require (
88
github.com/avast/retry-go/v4 v4.6.0
99
github.com/hashicorp/terraform-plugin-docs v0.18.0
1010
github.com/hashicorp/terraform-plugin-framework v1.13.0
11-
github.com/hashicorp/terraform-plugin-framework-validators v0.15.0
11+
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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ github.com/hashicorp/terraform-plugin-framework v1.13.0 h1:8OTG4+oZUfKgnfTdPTJwZ
113113
github.com/hashicorp/terraform-plugin-framework v1.13.0/go.mod h1:j64rwMGpgM3NYXTKuxrCnyubQb/4VKldEKlcG8cvmjU=
114114
github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0 h1:SJXL5FfJJm17554Kpt9jFXngdM6fXbnUnZ6iT2IeiYA=
115115
github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0/go.mod h1:p0phD0IYhsu9bR4+6OetVvvH59I6LwjXGnTVEr8ox6E=
116-
github.com/hashicorp/terraform-plugin-framework-validators v0.15.0 h1:RXMmu7JgpFjnI1a5QjMCBb11usrW2OtAG+iOTIj5c9Y=
117-
github.com/hashicorp/terraform-plugin-framework-validators v0.15.0/go.mod h1:Bh89/hNmqsEWug4/XWKYBwtnw3tbz5BAy1L1OgvbIaY=
116+
github.com/hashicorp/terraform-plugin-framework-validators v0.16.0 h1:O9QqGoYDzQT7lwTXUsZEtgabeWW96zUBh47Smn2lkFA=
117+
github.com/hashicorp/terraform-plugin-framework-validators v0.16.0/go.mod h1:Bh89/hNmqsEWug4/XWKYBwtnw3tbz5BAy1L1OgvbIaY=
118118
github.com/hashicorp/terraform-plugin-go v0.25.0 h1:oi13cx7xXA6QciMcpcFi/rwA974rdTxjqEhXJjbAyks=
119119
github.com/hashicorp/terraform-plugin-go v0.25.0/go.mod h1:+SYagMYadJP86Kvn+TGeV+ofr/R3g4/If0O5sO96MVw=
120120
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
@@ -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_subscription_resource.go

Lines changed: 53 additions & 1 deletion
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,
@@ -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/models/reverse_etl_model.go

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ import (
77
)
88

99
type ReverseETLModelState struct {
10-
ID types.String `tfsdk:"id"`
11-
SourceID types.String `tfsdk:"source_id"`
12-
Name types.String `tfsdk:"name"`
13-
Description types.String `tfsdk:"description"`
14-
Enabled types.Bool `tfsdk:"enabled"`
15-
ScheduleStrategy types.String `tfsdk:"schedule_strategy"`
16-
Query types.String `tfsdk:"query"`
17-
QueryIdentifierColumn types.String `tfsdk:"query_identifier_column"`
18-
ScheduleConfig jsontypes.Normalized `tfsdk:"schedule_config"`
10+
ID types.String `tfsdk:"id"`
11+
SourceID types.String `tfsdk:"source_id"`
12+
Name types.String `tfsdk:"name"`
13+
Description types.String `tfsdk:"description"`
14+
Enabled types.Bool `tfsdk:"enabled"`
15+
Query types.String `tfsdk:"query"`
16+
QueryIdentifierColumn types.String `tfsdk:"query_identifier_column"`
17+
18+
// Deprecated, schedule moved to destination_subscription
19+
ScheduleStrategy types.String `tfsdk:"schedule_strategy"`
20+
ScheduleConfig jsontypes.Normalized `tfsdk:"schedule_config"`
1921
}
2022

2123
func (r *ReverseETLModelState) Fill(model api.ReverseEtlModel) error {
@@ -24,35 +26,12 @@ func (r *ReverseETLModelState) Fill(model api.ReverseEtlModel) error {
2426
r.Name = types.StringValue(model.Name)
2527
r.Description = types.StringValue(model.Description)
2628
r.Enabled = types.BoolValue(model.Enabled)
27-
r.ScheduleStrategy = types.StringValue(model.ScheduleStrategy)
2829
r.Query = types.StringValue(model.Query)
2930
r.QueryIdentifierColumn = types.StringValue(model.QueryIdentifierColumn)
30-
scheduleConfig, err := GetScheduleConfig(model.ScheduleConfig)
31-
if err != nil {
32-
return err
33-
}
34-
r.ScheduleConfig = scheduleConfig
35-
if r.ScheduleConfig.IsNull() {
36-
empty := "{}"
37-
r.ScheduleConfig = jsontypes.NewNormalizedPointerValue(&empty)
38-
}
3931

40-
return nil
41-
}
42-
43-
func GetScheduleConfig(scheduleConfig api.NullableScheduleConfig) (jsontypes.Normalized, error) {
44-
if !scheduleConfig.IsSet() {
45-
return jsontypes.NewNormalizedNull(), nil
46-
}
32+
// Deprecated, schedule moved to destination_subscription
33+
r.ScheduleStrategy = types.StringPointerValue(nil)
34+
r.ScheduleConfig = jsontypes.NewNormalizedNull()
4735

48-
jsonScheduleConfigString, err := scheduleConfig.Get().MarshalJSON()
49-
if err != nil {
50-
return jsontypes.NewNormalizedNull(), err
51-
}
52-
53-
if jsonScheduleConfigString == nil {
54-
return jsontypes.NewNormalizedValue("{}"), nil
55-
}
56-
57-
return jsontypes.NewNormalizedValue(string(jsonScheduleConfigString)), nil
36+
return nil
5837
}

0 commit comments

Comments
 (0)