Skip to content

Commit

Permalink
Add serviceDirectoryRegistrations message to resource google_compute_…
Browse files Browse the repository at this point in the history
…global_forwarding_rule (#9485) (#1723)

* Add serviceDirectoryRegistrations in google_compute_global_forwarding_rule

* Add service_directory_registration message in example private_service_connect_google_apis.tf.erb

* Remove service field from service_directory_registration message as it is not currently applicable for globalForwardingRule
[upstream:087da54a4ca10340c889be9a11487eaa6e93bd99]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Nov 21, 2023
1 parent de06d33 commit 87b0dc6
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ func GetComputeGlobalForwardingRuleApiObject(d tpgresource.TerraformResourceData
} else if v, ok := d.GetOkExists("target"); !tpgresource.IsEmptyValue(reflect.ValueOf(targetProp)) && (ok || !reflect.DeepEqual(v, targetProp)) {
obj["target"] = targetProp
}
serviceDirectoryRegistrationsProp, err := expandComputeGlobalForwardingRuleServiceDirectoryRegistrations(d.Get("service_directory_registrations"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("service_directory_registrations"); !tpgresource.IsEmptyValue(reflect.ValueOf(serviceDirectoryRegistrationsProp)) && (ok || !reflect.DeepEqual(v, serviceDirectoryRegistrationsProp)) {
obj["serviceDirectoryRegistrations"] = serviceDirectoryRegistrationsProp
}
sourceIpRangesProp, err := expandComputeGlobalForwardingRuleSourceIpRanges(d.Get("source_ip_ranges"), d, config)
if err != nil {
return nil, err
Expand Down Expand Up @@ -277,6 +283,43 @@ func expandComputeGlobalForwardingRuleTarget(v interface{}, d tpgresource.Terraf
return v, nil
}

func expandComputeGlobalForwardingRuleServiceDirectoryRegistrations(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
req := make([]interface{}, 0, len(l))
for _, raw := range l {
if raw == nil {
continue
}
original := raw.(map[string]interface{})
transformed := make(map[string]interface{})

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

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

req = append(req, transformed)
}
return req, nil
}

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

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

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

0 comments on commit 87b0dc6

Please sign in to comment.