Fix crash when group_list has content in network data

This commit is contained in:
Kienan Stewart 2020-10-24 21:26:54 -04:00
parent 8c17f720c8
commit a4a1bc5f1f
1 changed files with 28 additions and 26 deletions

View File

@ -8,93 +8,95 @@ import (
rapi "burntworld.ca/go-rapi-client" rapi "burntworld.ca/go-rapi-client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func dataSourceNetworks() *schema.Resource { func dataSourceNetworks() *schema.Resource {
return &schema.Resource { return &schema.Resource{
ReadContext: dataSourceNetworksRead, ReadContext: dataSourceNetworksRead,
Schema: map[string]*schema.Schema { Schema: map[string]*schema.Schema{
"networks": &schema.Schema{ "networks": &schema.Schema{
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema { Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"ctime": &schema.Schema{ "ctime": &schema.Schema{
Type: schema.TypeFloat, Type: schema.TypeFloat,
Computed: true, Computed: true,
}, },
"external_reservations": &schema.Schema{ "external_reservations": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"free_count": &schema.Schema{ "free_count": &schema.Schema{
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"gateway": &schema.Schema{ "gateway": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"gateway6": &schema.Schema{ "gateway6": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"group_list": &schema.Schema{ "group_list": &schema.Schema{
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
Elem: &schema.Schema { Elem: &schema.Schema{
Type: schema.TypeString, Type: schema.TypeList,
Elemb: &schema.Schema{
Type: schema.TypeString,
},
}, },
}, },
"inst_list": &schema.Schema{ "inst_list": &schema.Schema{
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
Elem: &schema.Schema { Elem: &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
}, },
}, },
"mac_prefix": &schema.Schema{ "mac_prefix": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"map": &schema.Schema{ "map": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"mtime": &schema.Schema{ "mtime": &schema.Schema{
Type: schema.TypeFloat, Type: schema.TypeFloat,
Computed: true, Computed: true,
}, },
"network": &schema.Schema{ "network": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"network6": &schema.Schema{ "network6": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"reserved_count": &schema.Schema{ "reserved_count": &schema.Schema{
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"serial_no": &schema.Schema{ "serial_no": &schema.Schema{
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"tags": &schema.Schema{ "tags": &schema.Schema{
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
Elem: &schema.Schema { Elem: &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
}, },
}, },
"uuid": &schema.Schema{ "uuid": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
}, },