Skip to content

Commit ab18f60

Browse files
cakoosestack72
authored andcommitted
provider/ns1/record: Fix "use_client_subnet". (hashicorp#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.
1 parent 96f6044 commit ab18f60

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

builtin/providers/ns1/resource_record.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ func recordToResourceData(d *schema.ResourceData, r *dns.Record) error {
159159
// t := metaStructToDynamic(r.Meta)
160160
// d.Set("meta", t)
161161
// }
162+
if r.UseClientSubnet != nil {
163+
d.Set("use_client_subnet", *r.UseClientSubnet)
164+
}
162165
if len(r.Filters) > 0 {
163166
filters := make([]map[string]interface{}, len(r.Filters))
164167
for i, f := range r.Filters {
@@ -261,9 +264,9 @@ func resourceDataToRecord(r *dns.Record, d *schema.ResourceData) error {
261264
// if v, ok := d.GetOk("meta"); ok {
262265
// metaDynamicToStruct(r.Meta, v)
263266
// }
264-
useClientSubnetVal := d.Get("use_client_subnet").(bool)
265-
if v := strconv.FormatBool(useClientSubnetVal); v != "" {
266-
r.UseClientSubnet = &useClientSubnetVal
267+
if v, ok := d.GetOk("use_client_subnet"); ok {
268+
copy := v.(bool)
269+
r.UseClientSubnet = &copy
267270
}
268271

269272
if rawFilters := d.Get("filters").([]interface{}); len(rawFilters) > 0 {

0 commit comments

Comments
 (0)