mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-03 01:01:06 +00:00
Fix bug where flattened ip_address had extra empty element (#357)
The combination of append and preallocation of the ips caused extra empty elements at the beginning of the list.
This commit is contained in:
parent
a5b13bd6c6
commit
b29337dbfb
@ -1087,7 +1087,7 @@ func flattenReplicaConfiguration(replicaConfiguration *sqladmin.ReplicaConfigura
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenIpAddresses(ipAddresses []*sqladmin.IpMapping) []map[string]interface{} {
|
func flattenIpAddresses(ipAddresses []*sqladmin.IpMapping) []map[string]interface{} {
|
||||||
ips := make([]map[string]interface{}, len(ipAddresses))
|
var ips []map[string]interface{}
|
||||||
|
|
||||||
for _, ip := range ipAddresses {
|
for _, ip := range ipAddresses {
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
|
@ -422,6 +422,28 @@ func testAccCheckGoogleSqlDatabaseInstanceEquals(n string,
|
|||||||
return fmt.Errorf("Error master_instance_name mismatch, (%s, %s)", server, local)
|
return fmt.Errorf("Error master_instance_name mismatch, (%s, %s)", server, local)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ip_len, err := strconv.Atoi(attributes["ip_address.#"])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error parsing ip_addresses.# : %s", err.Error())
|
||||||
|
}
|
||||||
|
if ip_len != len(instance.IpAddresses) {
|
||||||
|
return fmt.Errorf("Error ip_addresses.# mismatch, server has %d but local has %d", len(instance.IpAddresses), ip_len)
|
||||||
|
}
|
||||||
|
// For now, assume the order matches
|
||||||
|
for idx, ip := range instance.IpAddresses {
|
||||||
|
server = attributes["ip_address."+strconv.Itoa(idx)+".ip_address"]
|
||||||
|
local = ip.IpAddress
|
||||||
|
if server != local {
|
||||||
|
return fmt.Errorf("Error ip_addresses.%d.ip_address mismatch, server has %s but local has %s", idx, server, local)
|
||||||
|
}
|
||||||
|
|
||||||
|
server = attributes["ip_address."+strconv.Itoa(idx)+".time_to_retire"]
|
||||||
|
local = ip.TimeToRetire
|
||||||
|
if server != local {
|
||||||
|
return fmt.Errorf("Error ip_addresses.%d.time_to_retire mismatch, server has %s but local has %s", idx, server, local)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
server = instance.Settings.ActivationPolicy
|
server = instance.Settings.ActivationPolicy
|
||||||
local = attributes["settings.0.activation_policy"]
|
local = attributes["settings.0.activation_policy"]
|
||||||
if server != local && len(server) > 0 && len(local) > 0 {
|
if server != local && len(server) > 0 && len(local) > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user