Skip to content

Commit 95bebba

Browse files
authored
Stop connecting sources and warehouses by default (#139)
1 parent 799cdc5 commit 95bebba

File tree

8 files changed

+53
-15
lines changed

8 files changed

+53
-15
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.1.0 (August 20, 2024)
2+
Stops connecting newly created sources and warehouses by default.
3+
14
## 1.0.5 (August 12, 2024)
25
Fixes a bug where user groups could not be cleared.
36

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.23.0
1313
github.com/hashicorp/terraform-plugin-testing v1.10.0
14-
github.com/segmentio/public-api-sdk-go v0.0.0-20231114153454-3be55fde5c99
14+
github.com/segmentio/public-api-sdk-go v0.0.0-20240909200753-311bb8d791a2
1515
gotest.tools/gotestsum v1.12.0
1616
)
1717

go.sum

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,20 @@ github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU
185185
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
186186
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
187187
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
188-
github.com/segmentio/public-api-sdk-go v0.0.0-20231114153454-3be55fde5c99 h1:55dfJRsEeZLLFln+0gQ1pNZvalFMyeMV9nTPQwShkok=
189-
github.com/segmentio/public-api-sdk-go v0.0.0-20231114153454-3be55fde5c99/go.mod h1:1mLoKkR7t90unwNx7qx9PicO3AX5NflFD7ny3TvLExU=
188+
github.com/segmentio/public-api-sdk-go v0.0.0-20240820173358-a52384e5ccc7 h1:04d9X+Bw1RY+lmbs0DajdA61xSQOZCAIUJuZfcFpz0g=
189+
github.com/segmentio/public-api-sdk-go v0.0.0-20240820173358-a52384e5ccc7/go.mod h1:yKkoPfcOkkYjiZQj4lRWxji0Qwc6ncNEf7wCfywochY=
190+
github.com/segmentio/public-api-sdk-go v0.0.0-20240820210528-faf5e1da4b4a h1:vSCltBxaOD5NRP3zGh/Xha3evkt0ZeXdAc6fTDTuwzg=
191+
github.com/segmentio/public-api-sdk-go v0.0.0-20240820210528-faf5e1da4b4a/go.mod h1:yKkoPfcOkkYjiZQj4lRWxji0Qwc6ncNEf7wCfywochY=
192+
github.com/segmentio/public-api-sdk-go v0.0.0-20240905000934-07e8214ff9da h1:SiFK2+vk+r2zEfUUZm2FbfY6F050L5zPzKsCGlvdUg4=
193+
github.com/segmentio/public-api-sdk-go v0.0.0-20240905000934-07e8214ff9da/go.mod h1:yKkoPfcOkkYjiZQj4lRWxji0Qwc6ncNEf7wCfywochY=
194+
github.com/segmentio/public-api-sdk-go v0.0.0-20240905231636-2922a096fe56 h1:IKxTy9Mw02je+m8AhpnYaKqrrjzBzHRn+Y99C4kGsEo=
195+
github.com/segmentio/public-api-sdk-go v0.0.0-20240905231636-2922a096fe56/go.mod h1:yKkoPfcOkkYjiZQj4lRWxji0Qwc6ncNEf7wCfywochY=
196+
github.com/segmentio/public-api-sdk-go v0.0.0-20240906231017-4e91c4889f50 h1:RsFkUN2lGzupgzXLsWdDdvsPp1oj6kwHLgucV77MPCk=
197+
github.com/segmentio/public-api-sdk-go v0.0.0-20240906231017-4e91c4889f50/go.mod h1:yKkoPfcOkkYjiZQj4lRWxji0Qwc6ncNEf7wCfywochY=
198+
github.com/segmentio/public-api-sdk-go v0.0.0-20240906235131-c22dd0e0d0b9 h1:g8gpxgqCPsFvOKhu55fPXl6H3wNm0CdbOH8cNri/1Fs=
199+
github.com/segmentio/public-api-sdk-go v0.0.0-20240906235131-c22dd0e0d0b9/go.mod h1:yKkoPfcOkkYjiZQj4lRWxji0Qwc6ncNEf7wCfywochY=
200+
github.com/segmentio/public-api-sdk-go v0.0.0-20240909200753-311bb8d791a2 h1:vlKTelJ32DPBuiiSx2PJaxN9jJd3OFK2avHU/XR/qB8=
201+
github.com/segmentio/public-api-sdk-go v0.0.0-20240909200753-311bb8d791a2/go.mod h1:yKkoPfcOkkYjiZQj4lRWxji0Qwc6ncNEf7wCfywochY=
190202
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
191203
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
192204
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=

internal/provider/function_resource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (r *functionResource) Create(ctx context.Context, req resource.CreateReques
159159
resp.State.SetAttribute(ctx, path.Root("id"), function.Id)
160160

161161
var state models.FunctionState
162-
state.Fill(api.Function(function))
162+
state.Fill(function)
163163

164164
// Destination functions append workspace name to display name causing inconsistency
165165
if state.ResourceType.ValueString() == "DESTINATION" || state.ResourceType.ValueString() == "INSERT_DESTINATION" {
@@ -256,7 +256,7 @@ func (r *functionResource) Update(ctx context.Context, req resource.UpdateReques
256256

257257
function := out.Data.GetFunction()
258258

259-
state.Fill(api.Function(function))
259+
state.Fill(function)
260260

261261
// Destination functions append workspace name to display name causing inconsistency
262262
if state.ResourceType.ValueString() == "DESTINATION" || state.ResourceType.ValueString() == "INSERT_DESTINATION" {

internal/provider/models/function.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type FunctionPlan struct {
4141
Settings types.Set `tfsdk:"settings"`
4242
}
4343

44-
func (f *FunctionState) Fill(function api.Function) {
44+
func (f *FunctionState) Fill(function api.FunctionV1) {
4545
f.ID = types.StringPointerValue(function.Id)
4646
f.Code = types.StringPointerValue(function.Code)
4747
f.DisplayName = types.StringPointerValue(function.DisplayName)

internal/provider/models/reverse_etl_model.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (r *ReverseETLModelState) Fill(model api.ReverseEtlModel) error {
2727
r.ScheduleStrategy = types.StringValue(model.ScheduleStrategy)
2828
r.Query = types.StringValue(model.Query)
2929
r.QueryIdentifierColumn = types.StringValue(model.QueryIdentifierColumn)
30-
scheduleConfig, err := GetSettings(model.ScheduleConfig)
30+
scheduleConfig, err := GetScheduleConfig(model.ScheduleConfig)
3131
if err != nil {
3232
return err
3333
}
@@ -39,3 +39,20 @@ func (r *ReverseETLModelState) Fill(model api.ReverseEtlModel) error {
3939

4040
return nil
4141
}
42+
43+
func GetScheduleConfig(scheduleConfig api.NullableScheduleConfig) (jsontypes.Normalized, error) {
44+
if !scheduleConfig.IsSet() {
45+
return jsontypes.NewNormalizedNull(), nil
46+
}
47+
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
58+
}

internal/provider/source_resource.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,14 @@ func (r *sourceResource) Create(ctx context.Context, req resource.CreateRequest,
276276
return
277277
}
278278

279+
disconnectAllWarehouses := true
280+
279281
out, body, err := r.client.SourcesAPI.CreateSource(r.authContext).CreateSourceV1Input(api.CreateSourceV1Input{
280-
Slug: plan.Slug.ValueString(),
281-
Enabled: plan.Enabled.ValueBool(),
282-
MetadataId: metadataID,
283-
Settings: settings,
282+
Slug: plan.Slug.ValueString(),
283+
Enabled: plan.Enabled.ValueBool(),
284+
MetadataId: metadataID,
285+
Settings: settings,
286+
DisconnectAllWarehouses: &disconnectAllWarehouses,
284287
}).Execute()
285288
if body != nil {
286289
defer body.Body.Close()

internal/provider/warehouse_resource.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,14 @@ func (r *warehouseResource) Create(ctx context.Context, req resource.CreateReque
219219
name = nil
220220
}
221221

222+
disconnectAllSources := true
223+
222224
out, body, err := r.client.WarehousesAPI.CreateWarehouse(r.authContext).CreateWarehouseV1Input(api.CreateWarehouseV1Input{
223-
Enabled: plan.Enabled.ValueBoolPointer(),
224-
MetadataId: metadataID,
225-
Settings: settings,
226-
Name: name,
225+
Enabled: plan.Enabled.ValueBoolPointer(),
226+
MetadataId: metadataID,
227+
Settings: settings,
228+
Name: name,
229+
DisconnectAllSources: &disconnectAllSources,
227230
}).Execute()
228231
if body != nil {
229232
defer body.Body.Close()

0 commit comments

Comments
 (0)