Skip to content

Commit

Permalink
Support FOR_MIGRATION InternalRange objects (#11856) (#2896)
Browse files Browse the repository at this point in the history
[upstream:b6675939e5afa0113e79ec31076c93d7021adc46]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Oct 4, 2024
1 parent c2f69e3 commit 4a87264
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ func GetNetworkConnectivityInternalRangeApiObject(d tpgresource.TerraformResourc
} else if v, ok := d.GetOkExists("overlaps"); !tpgresource.IsEmptyValue(reflect.ValueOf(overlapsProp)) && (ok || !reflect.DeepEqual(v, overlapsProp)) {
obj["overlaps"] = overlapsProp
}
migrationProp, err := expandNetworkConnectivityInternalRangeMigration(d.Get("migration"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("migration"); !tpgresource.IsEmptyValue(reflect.ValueOf(migrationProp)) && (ok || !reflect.DeepEqual(v, migrationProp)) {
obj["migration"] = migrationProp
}
labelsProp, err := expandNetworkConnectivityInternalRangeEffectiveLabels(d.Get("effective_labels"), d, config)
if err != nil {
return nil, err
Expand Down Expand Up @@ -144,6 +150,40 @@ func expandNetworkConnectivityInternalRangeOverlaps(v interface{}, d tpgresource
return v, nil
}

func expandNetworkConnectivityInternalRangeMigration(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
original := raw.(map[string]interface{})
transformed := make(map[string]interface{})

transformedSource, err := expandNetworkConnectivityInternalRangeMigrationSource(original["source"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedSource); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["source"] = transformedSource
}

transformedTarget, err := expandNetworkConnectivityInternalRangeMigrationTarget(original["target"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedTarget); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["target"] = transformedTarget
}

return transformed, nil
}

func expandNetworkConnectivityInternalRangeMigrationSource(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandNetworkConnectivityInternalRangeMigrationTarget(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandNetworkConnectivityInternalRangeEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
if v == nil {
return map[string]string{}, nil
Expand Down

0 comments on commit 4a87264

Please sign in to comment.