mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-05 17:52:38 +00:00
Change authorized_networks to set (#733)
This commit is contained in:
parent
182f87835b
commit
6adbdcfaee
|
@ -14,6 +14,23 @@ import (
|
|||
"google.golang.org/api/sqladmin/v1beta4"
|
||||
)
|
||||
|
||||
var sqlDatabaseAuthorizedNetWorkSchemaElem *schema.Resource = &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"expiration_time": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"value": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func resourceSqlDatabaseInstance() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Create: resourceSqlDatabaseInstanceCreate,
|
||||
|
@ -128,24 +145,10 @@ func resourceSqlDatabaseInstance() *schema.Resource {
|
|||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"authorized_networks": &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"expiration_time": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"value": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Set: schema.HashResource(sqlDatabaseAuthorizedNetWorkSchemaElem),
|
||||
Elem: sqlDatabaseAuthorizedNetWorkSchemaElem,
|
||||
},
|
||||
"ipv4_enabled": &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
|
@ -458,7 +461,7 @@ func resourceSqlDatabaseInstanceCreate(d *schema.ResourceData, meta interface{})
|
|||
|
||||
if vp, okp := _ipConfiguration["authorized_networks"]; okp {
|
||||
settings.IpConfiguration.AuthorizedNetworks = make([]*sqladmin.AclEntry, 0)
|
||||
_authorizedNetworksList := vp.([]interface{})
|
||||
_authorizedNetworksList := vp.(*schema.Set).List()
|
||||
for _, _acl := range _authorizedNetworksList {
|
||||
_entry := _acl.(map[string]interface{})
|
||||
entry := &sqladmin.AclEntry{}
|
||||
|
@ -835,7 +838,7 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{})
|
|||
if len(_oldIpConfList) > 0 {
|
||||
_oldIpConf := _oldIpConfList[0].(map[string]interface{})
|
||||
if ovp, ookp := _oldIpConf["authorized_networks"]; ookp {
|
||||
_oldAuthorizedNetworkList = ovp.([]interface{})
|
||||
_oldAuthorizedNetworkList = ovp.(*schema.Set).List()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -846,7 +849,7 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{})
|
|||
|
||||
_authorizedNetworksList := make([]interface{}, 0)
|
||||
if vp != nil {
|
||||
_authorizedNetworksList = vp.([]interface{})
|
||||
_authorizedNetworksList = vp.(*schema.Set).List()
|
||||
}
|
||||
_oipc_map := make(map[string]interface{})
|
||||
for _, _ipc := range _oldAuthorizedNetworkList {
|
||||
|
@ -1050,7 +1053,7 @@ func flattenIpConfiguration(ipConfiguration *sqladmin.IpConfiguration) interface
|
|||
}
|
||||
|
||||
func flattenAuthorizedNetworks(entries []*sqladmin.AclEntry) interface{} {
|
||||
networks := make([]map[string]interface{}, 0, len(entries))
|
||||
networks := schema.NewSet(schema.HashResource(sqlDatabaseAuthorizedNetWorkSchemaElem), []interface{}{})
|
||||
|
||||
for _, entry := range entries {
|
||||
data := map[string]interface{}{
|
||||
|
@ -1059,7 +1062,7 @@ func flattenAuthorizedNetworks(entries []*sqladmin.AclEntry) interface{} {
|
|||
"value": entry.Value,
|
||||
}
|
||||
|
||||
networks = append(networks, data)
|
||||
networks.Add(data)
|
||||
}
|
||||
|
||||
return networks
|
||||
|
|
Loading…
Reference in New Issue
Block a user