diff --git a/converters/google/resources/compute_forwarding_rule.go b/converters/google/resources/compute_forwarding_rule.go index 83ccf0937..9130f1e05 100644 --- a/converters/google/resources/compute_forwarding_rule.go +++ b/converters/google/resources/compute_forwarding_rule.go @@ -144,6 +144,12 @@ func GetComputeForwardingRuleApiObject(d TerraformResourceData, config *Config) } else if v, ok := d.GetOkExists("network_tier"); !isEmptyValue(reflect.ValueOf(networkTierProp)) && (ok || !reflect.DeepEqual(v, networkTierProp)) { obj["networkTier"] = networkTierProp } + serviceDirectoryRegistrationsProp, err := expandComputeForwardingRuleServiceDirectoryRegistrations(d.Get("service_directory_registrations"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("service_directory_registrations"); !isEmptyValue(reflect.ValueOf(serviceDirectoryRegistrationsProp)) && (ok || !reflect.DeepEqual(v, serviceDirectoryRegistrationsProp)) { + obj["serviceDirectoryRegistrations"] = serviceDirectoryRegistrationsProp + } serviceLabelProp, err := expandComputeForwardingRuleServiceLabel(d.Get("service_label"), d, config) if err != nil { return nil, err @@ -286,6 +292,43 @@ func expandComputeForwardingRuleNetworkTier(v interface{}, d TerraformResourceDa return v, nil } +func expandComputeForwardingRuleServiceDirectoryRegistrations(v interface{}, d TerraformResourceData, config *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 := expandComputeForwardingRuleServiceDirectoryRegistrationsNamespace(original["namespace"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedNamespace); val.IsValid() && !isEmptyValue(val) { + transformed["namespace"] = transformedNamespace + } + + transformedService, err := expandComputeForwardingRuleServiceDirectoryRegistrationsService(original["service"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedService); val.IsValid() && !isEmptyValue(val) { + transformed["service"] = transformedService + } + + req = append(req, transformed) + } + return req, nil +} + +func expandComputeForwardingRuleServiceDirectoryRegistrationsNamespace(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeForwardingRuleServiceDirectoryRegistrationsService(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + func expandComputeForwardingRuleServiceLabel(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { return v, nil } diff --git a/go.mod b/go.mod index 5db3e4296..f5a3c336e 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/hashicorp/go-cleanhttp v0.5.2 github.com/hashicorp/terraform-json v0.13.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1 - github.com/hashicorp/terraform-provider-google v1.20.1-0.20220503202841-7b292958f370 + github.com/hashicorp/terraform-provider-google v1.20.1-0.20220503225942-7ed0be6b4fa1 github.com/kr/pretty v0.3.0 // indirect github.com/mitchellh/go-homedir v1.1.0 github.com/onsi/gomega v1.17.0 // indirect diff --git a/go.sum b/go.sum index 9bfe570d7..5f62812ea 100644 --- a/go.sum +++ b/go.sum @@ -82,8 +82,8 @@ github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3 github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= github.com/GoogleCloudPlatform/config-validator v0.0.0-20211122204404-f3fd77c5c355 h1:UQQJmJl5aZNwLISiq/YqEEFXxv042cYY6wD49TOzrco= github.com/GoogleCloudPlatform/config-validator v0.0.0-20211122204404-f3fd77c5c355/go.mod h1:MHzWJNkQiBhSRuWAOxdMBBR+acz6g+jXGDtZp5S7vzU= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.1.0 h1:6EDY4EUsCW/mTRzYJ8SEzL2V5JACYCiIswnbhpaAwaY= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.1.0/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.5.1 h1:WsauUAtzKxwcfR2SAN8K/yeHS6S4pGK6r/oJdKJaTgI= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.5.1/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E= github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= @@ -696,8 +696,8 @@ github.com/hashicorp/terraform-plugin-log v0.2.0 h1:rjflRuBqCnSk3UHOR25MP1G5BDLK github.com/hashicorp/terraform-plugin-log v0.2.0/go.mod h1:E1kJmapEHzqu1x6M++gjvhzM2yMQNXPVWZRCB8sgYjg= github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1 h1:B9AocC+dxrCqcf4vVhztIkSkt3gpRjUkEka8AmZWGlQ= github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1/go.mod h1:FjM9DXWfP0w/AeOtJoSKHBZ01LqmaO6uP4bXhv3fekw= -github.com/hashicorp/terraform-provider-google v1.20.1-0.20220503202841-7b292958f370 h1:03B4gL/2eQFjyPjuMLN4G5CzV6AP/8gL41L2TNt6SOI= -github.com/hashicorp/terraform-provider-google v1.20.1-0.20220503202841-7b292958f370/go.mod h1:zuersTi7DrjFzHJ9B6noGikoBdHD6EJj6RlQ2YMQNb4= +github.com/hashicorp/terraform-provider-google v1.20.1-0.20220503225942-7ed0be6b4fa1 h1:xfYiAmW7baDbJIpyP7RgRi4LBx4bC1gH9rt7YKOvkTM= +github.com/hashicorp/terraform-provider-google v1.20.1-0.20220503225942-7ed0be6b4fa1/go.mod h1:BnEfYV7B6sSfn86tYCV8r8no9OYHsBXJCoix04P7b6I= github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 h1:1FGtlkJw87UsTMg5s8jrekrHmUPUJaMcu6ELiVhQrNw= github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896/go.mod h1:bzBPnUIkI0RxauU8Dqo+2KrZZ28Cf48s8V6IHt3p4co= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=