provider/ns1/record: Fix "use_client_subnet". (#11368)

The support for "use_client_subnet" was half finished.
- Field was defined in schema.
- ResourceData-to-struct code was present but incorrect.
- struct-to-ResourceData code was missing.

Made the change and verified with manual testing:
1. In NS1 UI, switched "Use Client Subnet" between checked and
   unchecked.
2. In Terraform config file, switched "use_client_subnet" field between
   "true", "false", and omitted.
3. The output of "terraform plan" was as expected in all six cases.
This commit is contained in:
Kannan Goundan 2017-01-29 08:45:13 -08:00 committed by Paul Stack
parent 96f6044908
commit ab18f60071
1 changed files with 6 additions and 3 deletions

View File

@ -159,6 +159,9 @@ func recordToResourceData(d *schema.ResourceData, r *dns.Record) error {
// t := metaStructToDynamic(r.Meta)
// d.Set("meta", t)
// }
if r.UseClientSubnet != nil {
d.Set("use_client_subnet", *r.UseClientSubnet)
}
if len(r.Filters) > 0 {
filters := make([]map[string]interface{}, len(r.Filters))
for i, f := range r.Filters {
@ -261,9 +264,9 @@ func resourceDataToRecord(r *dns.Record, d *schema.ResourceData) error {
// if v, ok := d.GetOk("meta"); ok {
// metaDynamicToStruct(r.Meta, v)
// }
useClientSubnetVal := d.Get("use_client_subnet").(bool)
if v := strconv.FormatBool(useClientSubnetVal); v != "" {
r.UseClientSubnet = &useClientSubnetVal
if v, ok := d.GetOk("use_client_subnet"); ok {
copy := v.(bool)
r.UseClientSubnet = &copy
}
if rawFilters := d.Get("filters").([]interface{}); len(rawFilters) > 0 {