mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-06 18:51:13 +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"
|
"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 {
|
func resourceSqlDatabaseInstance() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
Create: resourceSqlDatabaseInstanceCreate,
|
Create: resourceSqlDatabaseInstanceCreate,
|
||||||
@ -128,24 +145,10 @@ func resourceSqlDatabaseInstance() *schema.Resource {
|
|||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"authorized_networks": &schema.Schema{
|
"authorized_networks": &schema.Schema{
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeSet,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Elem: &schema.Resource{
|
Set: schema.HashResource(sqlDatabaseAuthorizedNetWorkSchemaElem),
|
||||||
Schema: map[string]*schema.Schema{
|
Elem: sqlDatabaseAuthorizedNetWorkSchemaElem,
|
||||||
"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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"ipv4_enabled": &schema.Schema{
|
"ipv4_enabled": &schema.Schema{
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
@ -458,7 +461,7 @@ func resourceSqlDatabaseInstanceCreate(d *schema.ResourceData, meta interface{})
|
|||||||
|
|
||||||
if vp, okp := _ipConfiguration["authorized_networks"]; okp {
|
if vp, okp := _ipConfiguration["authorized_networks"]; okp {
|
||||||
settings.IpConfiguration.AuthorizedNetworks = make([]*sqladmin.AclEntry, 0)
|
settings.IpConfiguration.AuthorizedNetworks = make([]*sqladmin.AclEntry, 0)
|
||||||
_authorizedNetworksList := vp.([]interface{})
|
_authorizedNetworksList := vp.(*schema.Set).List()
|
||||||
for _, _acl := range _authorizedNetworksList {
|
for _, _acl := range _authorizedNetworksList {
|
||||||
_entry := _acl.(map[string]interface{})
|
_entry := _acl.(map[string]interface{})
|
||||||
entry := &sqladmin.AclEntry{}
|
entry := &sqladmin.AclEntry{}
|
||||||
@ -835,7 +838,7 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{})
|
|||||||
if len(_oldIpConfList) > 0 {
|
if len(_oldIpConfList) > 0 {
|
||||||
_oldIpConf := _oldIpConfList[0].(map[string]interface{})
|
_oldIpConf := _oldIpConfList[0].(map[string]interface{})
|
||||||
if ovp, ookp := _oldIpConf["authorized_networks"]; ookp {
|
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)
|
_authorizedNetworksList := make([]interface{}, 0)
|
||||||
if vp != nil {
|
if vp != nil {
|
||||||
_authorizedNetworksList = vp.([]interface{})
|
_authorizedNetworksList = vp.(*schema.Set).List()
|
||||||
}
|
}
|
||||||
_oipc_map := make(map[string]interface{})
|
_oipc_map := make(map[string]interface{})
|
||||||
for _, _ipc := range _oldAuthorizedNetworkList {
|
for _, _ipc := range _oldAuthorizedNetworkList {
|
||||||
@ -1050,7 +1053,7 @@ func flattenIpConfiguration(ipConfiguration *sqladmin.IpConfiguration) interface
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenAuthorizedNetworks(entries []*sqladmin.AclEntry) 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 {
|
for _, entry := range entries {
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
@ -1059,7 +1062,7 @@ func flattenAuthorizedNetworks(entries []*sqladmin.AclEntry) interface{} {
|
|||||||
"value": entry.Value,
|
"value": entry.Value,
|
||||||
}
|
}
|
||||||
|
|
||||||
networks = append(networks, data)
|
networks.Add(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
return networks
|
return networks
|
||||||
|
Loading…
Reference in New Issue
Block a user