From 349522e41e300bcd81871fb292a9047840541e62 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Wed, 19 Oct 2022 20:01:24 +0000 Subject: [PATCH] google_vpc_access_connector missing GA args (#6718) Signed-off-by: Modular Magician --- .../google/resources/vpcaccess_connector.go | 70 +++++++++++++++++++ go.mod | 2 +- go.sum | 4 +- 3 files changed, 73 insertions(+), 3 deletions(-) diff --git a/converters/google/resources/vpcaccess_connector.go b/converters/google/resources/vpcaccess_connector.go index d9b88f695..ba377e1c0 100644 --- a/converters/google/resources/vpcaccess_connector.go +++ b/converters/google/resources/vpcaccess_connector.go @@ -66,18 +66,42 @@ func GetVPCAccessConnectorApiObject(d TerraformResourceData, config *Config) (ma } else if v, ok := d.GetOkExists("ip_cidr_range"); !isEmptyValue(reflect.ValueOf(ipCidrRangeProp)) && (ok || !reflect.DeepEqual(v, ipCidrRangeProp)) { obj["ipCidrRange"] = ipCidrRangeProp } + machineTypeProp, err := expandVPCAccessConnectorMachineType(d.Get("machine_type"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("machine_type"); !isEmptyValue(reflect.ValueOf(machineTypeProp)) && (ok || !reflect.DeepEqual(v, machineTypeProp)) { + obj["machineType"] = machineTypeProp + } minThroughputProp, err := expandVPCAccessConnectorMinThroughput(d.Get("min_throughput"), d, config) if err != nil { return nil, err } else if v, ok := d.GetOkExists("min_throughput"); !isEmptyValue(reflect.ValueOf(minThroughputProp)) && (ok || !reflect.DeepEqual(v, minThroughputProp)) { obj["minThroughput"] = minThroughputProp } + minInstancesProp, err := expandVPCAccessConnectorMinInstances(d.Get("min_instances"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("min_instances"); !isEmptyValue(reflect.ValueOf(minInstancesProp)) && (ok || !reflect.DeepEqual(v, minInstancesProp)) { + obj["minInstances"] = minInstancesProp + } + maxInstancesProp, err := expandVPCAccessConnectorMaxInstances(d.Get("max_instances"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("max_instances"); !isEmptyValue(reflect.ValueOf(maxInstancesProp)) && (ok || !reflect.DeepEqual(v, maxInstancesProp)) { + obj["maxInstances"] = maxInstancesProp + } maxThroughputProp, err := expandVPCAccessConnectorMaxThroughput(d.Get("max_throughput"), d, config) if err != nil { return nil, err } else if v, ok := d.GetOkExists("max_throughput"); !isEmptyValue(reflect.ValueOf(maxThroughputProp)) && (ok || !reflect.DeepEqual(v, maxThroughputProp)) { obj["maxThroughput"] = maxThroughputProp } + subnetProp, err := expandVPCAccessConnectorSubnet(d.Get("subnet"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("subnet"); !isEmptyValue(reflect.ValueOf(subnetProp)) && (ok || !reflect.DeepEqual(v, subnetProp)) { + obj["subnet"] = subnetProp + } return resourceVPCAccessConnectorEncoder(d, config, obj) } @@ -99,10 +123,56 @@ func expandVPCAccessConnectorIpCidrRange(v interface{}, d TerraformResourceData, return v, nil } +func expandVPCAccessConnectorMachineType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + func expandVPCAccessConnectorMinThroughput(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { return v, nil } +func expandVPCAccessConnectorMinInstances(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandVPCAccessConnectorMaxInstances(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + func expandVPCAccessConnectorMaxThroughput(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { return v, nil } + +func expandVPCAccessConnectorSubnet(v interface{}, d TerraformResourceData, config *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{}) + + transformedName, err := expandVPCAccessConnectorSubnetName(original["name"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedName); val.IsValid() && !isEmptyValue(val) { + transformed["name"] = transformedName + } + + transformedProjectId, err := expandVPCAccessConnectorSubnetProjectId(original["project_id"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedProjectId); val.IsValid() && !isEmptyValue(val) { + transformed["projectId"] = transformedProjectId + } + + return transformed, nil +} + +func expandVPCAccessConnectorSubnetName(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandVPCAccessConnectorSubnetProjectId(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} diff --git a/go.mod b/go.mod index 6b1bf2f75..8fad31e97 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/hashicorp/go-cleanhttp v0.5.2 github.com/hashicorp/terraform-json v0.14.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.18.0 - github.com/hashicorp/terraform-provider-google v1.20.1-0.20221019174133-f25b67ad6cef + github.com/hashicorp/terraform-provider-google v1.20.1-0.20221019195723-06eae6abd2b1 github.com/mitchellh/go-homedir v1.1.0 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.8.1 diff --git a/go.sum b/go.sum index dcb0d8d6e..12c724f43 100644 --- a/go.sum +++ b/go.sum @@ -653,8 +653,8 @@ github.com/hashicorp/terraform-plugin-log v0.4.1 h1:xpbmVhvuU3mgHzLetOmx9pkOL2rm github.com/hashicorp/terraform-plugin-log v0.4.1/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4= github.com/hashicorp/terraform-plugin-sdk/v2 v2.18.0 h1:/cdI5di5XA+N80gXzXF4YcHq36DprBskubk6Z8i26ZQ= github.com/hashicorp/terraform-plugin-sdk/v2 v2.18.0/go.mod h1:L3SHkD/Q8zPVgXviQmpVwy9nKwpXXZscVIpVEnQ/T50= -github.com/hashicorp/terraform-provider-google v1.20.1-0.20221019174133-f25b67ad6cef h1:SxWVU+CJkkwF1xyjvV1B6Ve3JC6EsINXpAqC3KK7Mdw= -github.com/hashicorp/terraform-provider-google v1.20.1-0.20221019174133-f25b67ad6cef/go.mod h1:TXv5NcGqgwMoBrbw5PL5WFEHMR4pJZiorclCbnZT024= +github.com/hashicorp/terraform-provider-google v1.20.1-0.20221019195723-06eae6abd2b1 h1:keJ4JZX5T8w5LuSGpX5wi+IYEwKf6foiCNp8/wQL+jw= +github.com/hashicorp/terraform-provider-google v1.20.1-0.20221019195723-06eae6abd2b1/go.mod h1:TXv5NcGqgwMoBrbw5PL5WFEHMR4pJZiorclCbnZT024= github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg= github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=