mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-16 18:35:03 -06:00
Merge pull request #8290 from lwander/b-gcp-sql-instance-auth-networks
provider/google: Correct update process for auth nets in sql instance
This commit is contained in:
commit
7b898b8f95
@ -617,9 +617,13 @@ func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) e
|
|||||||
}
|
}
|
||||||
|
|
||||||
if vp, okp := _ipConfiguration["authorized_networks"]; okp && vp != nil {
|
if vp, okp := _ipConfiguration["authorized_networks"]; okp && vp != nil {
|
||||||
|
_authorizedNetworksList := vp.([]interface{})
|
||||||
_ipc_map := make(map[string]interface{})
|
_ipc_map := make(map[string]interface{})
|
||||||
// First keep track of localy defined ip configurations
|
// First keep track of locally defined ip configurations
|
||||||
for _, _ipc := range _ipConfigurationList {
|
for _, _ipc := range _authorizedNetworksList {
|
||||||
|
if _ipc == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
_entry := _ipc.(map[string]interface{})
|
_entry := _ipc.(map[string]interface{})
|
||||||
if _entry["value"] == nil {
|
if _entry["value"] == nil {
|
||||||
continue
|
continue
|
||||||
@ -911,7 +915,7 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{})
|
|||||||
}
|
}
|
||||||
|
|
||||||
if vp, okp := _ipConfiguration["authorized_networks"]; okp || len(_oldAuthorizedNetworkList) > 0 {
|
if vp, okp := _ipConfiguration["authorized_networks"]; okp || len(_oldAuthorizedNetworkList) > 0 {
|
||||||
oldAuthorizedNetworks := settings.IpConfiguration.AuthorizedNetworks
|
oldAuthorizedNetworks := instance.Settings.IpConfiguration.AuthorizedNetworks
|
||||||
settings.IpConfiguration.AuthorizedNetworks = make([]*sqladmin.AclEntry, 0)
|
settings.IpConfiguration.AuthorizedNetworks = make([]*sqladmin.AclEntry, 0)
|
||||||
|
|
||||||
_authorizedNetworksList := make([]interface{}, 0)
|
_authorizedNetworksList := make([]interface{}, 0)
|
||||||
@ -932,28 +936,26 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{})
|
|||||||
settings.IpConfiguration.AuthorizedNetworks, entry)
|
settings.IpConfiguration.AuthorizedNetworks, entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// finally, insert only those that were previously defined
|
// finally, update old entries and insert new ones
|
||||||
// and are still defined.
|
// and are still defined.
|
||||||
for _, _ipc := range _authorizedNetworksList {
|
for _, _ipc := range _authorizedNetworksList {
|
||||||
_entry := _ipc.(map[string]interface{})
|
_entry := _ipc.(map[string]interface{})
|
||||||
if _, ok_old := _oipc_map[_entry["value"].(string)]; ok_old {
|
entry := &sqladmin.AclEntry{}
|
||||||
entry := &sqladmin.AclEntry{}
|
|
||||||
|
|
||||||
if vpp, okpp := _entry["expiration_time"]; okpp {
|
if vpp, okpp := _entry["expiration_time"]; okpp {
|
||||||
entry.ExpirationTime = vpp.(string)
|
entry.ExpirationTime = vpp.(string)
|
||||||
}
|
|
||||||
|
|
||||||
if vpp, okpp := _entry["name"]; okpp {
|
|
||||||
entry.Name = vpp.(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
if vpp, okpp := _entry["value"]; okpp {
|
|
||||||
entry.Value = vpp.(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
settings.IpConfiguration.AuthorizedNetworks = append(
|
|
||||||
settings.IpConfiguration.AuthorizedNetworks, entry)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if vpp, okpp := _entry["name"]; okpp {
|
||||||
|
entry.Name = vpp.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
if vpp, okpp := _entry["value"]; okpp {
|
||||||
|
entry.Value = vpp.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.IpConfiguration.AuthorizedNetworks = append(
|
||||||
|
settings.IpConfiguration.AuthorizedNetworks, entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user