Skip to content

Commit 0d78102

Browse files
Datastream - Add mysql backfill max tasks (#7924) (#14639)
* Add mysql backfill max tasks * Add mysql backfill max tasks to tests Signed-off-by: Modular Magician <[email protected]>
1 parent e4e15b9 commit 0d78102

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

.changelog/7924.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
datastream: added `mysql_source_config.max_concurrent_backfill_tasks` field to `google_datastream_stream` resource
3+
```

google/resource_datastream_stream.go

+38
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,14 @@ https://dev.mysql.com/doc/refman/8.0/en/data-types.html`,
479479
},
480480
},
481481
},
482+
"max_concurrent_backfill_tasks": {
483+
Type: schema.TypeInt,
484+
Computed: true,
485+
Optional: true,
486+
ValidateFunc: validation.IntAtLeast(0),
487+
Description: `Maximum number of concurrent backfill tasks. The number should be non negative.
488+
If not set (or set to 0), the system's default value will be used.`,
489+
},
482490
"max_concurrent_cdc_tasks": {
483491
Type: schema.TypeInt,
484492
Computed: true,
@@ -1741,6 +1749,8 @@ func flattenDatastreamStreamSourceConfigMysqlSourceConfig(v interface{}, d *sche
17411749
flattenDatastreamStreamSourceConfigMysqlSourceConfigExcludeObjects(original["excludeObjects"], d, config)
17421750
transformed["max_concurrent_cdc_tasks"] =
17431751
flattenDatastreamStreamSourceConfigMysqlSourceConfigMaxConcurrentCdcTasks(original["maxConcurrentCdcTasks"], d, config)
1752+
transformed["max_concurrent_backfill_tasks"] =
1753+
flattenDatastreamStreamSourceConfigMysqlSourceConfigMaxConcurrentBackfillTasks(original["maxConcurrentBackfillTasks"], d, config)
17441754
return []interface{}{transformed}
17451755
}
17461756
func flattenDatastreamStreamSourceConfigMysqlSourceConfigIncludeObjects(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -2034,6 +2044,23 @@ func flattenDatastreamStreamSourceConfigMysqlSourceConfigMaxConcurrentCdcTasks(v
20342044
return v // let terraform core handle it otherwise
20352045
}
20362046

2047+
func flattenDatastreamStreamSourceConfigMysqlSourceConfigMaxConcurrentBackfillTasks(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
2048+
// Handles the string fixed64 format
2049+
if strVal, ok := v.(string); ok {
2050+
if intVal, err := StringToFixed64(strVal); err == nil {
2051+
return intVal
2052+
}
2053+
}
2054+
2055+
// number values are represented as float64
2056+
if floatVal, ok := v.(float64); ok {
2057+
intVal := int(floatVal)
2058+
return intVal
2059+
}
2060+
2061+
return v // let terraform core handle it otherwise
2062+
}
2063+
20372064
func flattenDatastreamStreamSourceConfigOracleSourceConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
20382065
if v == nil {
20392066
return nil
@@ -3609,6 +3636,13 @@ func expandDatastreamStreamSourceConfigMysqlSourceConfig(v interface{}, d tpgres
36093636
transformed["maxConcurrentCdcTasks"] = transformedMaxConcurrentCdcTasks
36103637
}
36113638

3639+
transformedMaxConcurrentBackfillTasks, err := expandDatastreamStreamSourceConfigMysqlSourceConfigMaxConcurrentBackfillTasks(original["max_concurrent_backfill_tasks"], d, config)
3640+
if err != nil {
3641+
return nil, err
3642+
} else {
3643+
transformed["maxConcurrentBackfillTasks"] = transformedMaxConcurrentBackfillTasks
3644+
}
3645+
36123646
return transformed, nil
36133647
}
36143648

@@ -3970,6 +4004,10 @@ func expandDatastreamStreamSourceConfigMysqlSourceConfigMaxConcurrentCdcTasks(v
39704004
return v, nil
39714005
}
39724006

4007+
func expandDatastreamStreamSourceConfigMysqlSourceConfigMaxConcurrentBackfillTasks(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
4008+
return v, nil
4009+
}
4010+
39734011
func expandDatastreamStreamSourceConfigOracleSourceConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
39744012
l := v.([]interface{})
39754013
if len(l) == 0 {

google/resource_datastream_stream_generated_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ resource "google_datastream_stream" "default" {
172172
display_name = "my stream"
173173
source_config {
174174
source_connection_profile = google_datastream_connection_profile.source_connection_profile.id
175-
mysql_source_config {}
175+
mysql_source_config {
176+
max_concurrent_backfill_tasks = 15
177+
}
176178
}
177179
destination_config {
178180
destination_connection_profile = google_datastream_connection_profile.destination_connection_profile.id

website/docs/r/datastream_stream.html.markdown

+5
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,11 @@ The following arguments are supported:
721721
Maximum number of concurrent CDC tasks. The number should be non negative.
722722
If not set (or set to 0), the system's default value will be used.
723723

724+
* `max_concurrent_backfill_tasks` -
725+
(Optional)
726+
Maximum number of concurrent backfill tasks. The number should be non negative.
727+
If not set (or set to 0), the system's default value will be used.
728+
724729

725730
<a name="nested_include_objects"></a>The `include_objects` block supports:
726731

0 commit comments

Comments
 (0)