Skip to content

Commit

Permalink
fix: Unable to remove description for some resources
Browse files Browse the repository at this point in the history
  • Loading branch information
smutel committed Oct 31, 2020
1 parent 6e87ef7 commit f340062
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
10 changes: 9 additions & 1 deletion netbox/resource_netbox_ipam_ip_addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func resourceNetboxIpamIPAddresses() *schema.Resource {
"description": {
Type: schema.TypeString,
Optional: true,
Default: " ",
ValidateFunc: validation.StringLenBetween(1, 100),
},
"dns_name": {
Expand Down Expand Up @@ -180,7 +181,14 @@ func resourceNetboxIpamIPAddressesRead(d *schema.ResourceData,
return err
}

if err = d.Set("description", resource.Description); err != nil {
var description string
if resource.Description == "" {
description = " "
} else {
description = resource.Description
}

if err = d.Set("description", description); err != nil {
return err
}

Expand Down
11 changes: 10 additions & 1 deletion netbox/resource_netbox_ipam_prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func resourceNetboxIpamPrefix() *schema.Resource {
"description": {
Type: schema.TypeString,
Optional: true,
Default: " ",
ValidateFunc: validation.StringLenBetween(1, 100),
},
"is_pool": {
Expand Down Expand Up @@ -150,7 +151,15 @@ func resourceNetboxIpamPrefixRead(d *schema.ResourceData,

for _, resource := range resources.Payload.Results {
if strconv.FormatInt(resource.ID, 10) == d.Id() {
if err = d.Set("description", resource.Description); err != nil {
var description string

if resource.Description == "" {
description = " "
} else {
description = resource.Description
}

if err = d.Set("description", description); err != nil {
return err
}

Expand Down
11 changes: 10 additions & 1 deletion netbox/resource_netbox_ipam_vlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func resourceNetboxIpamVlan() *schema.Resource {
"description": {
Type: schema.TypeString,
Optional: true,
Default: " ",
ValidateFunc: validation.StringLenBetween(1, 100),
},
"vlan_group_id": {
Expand Down Expand Up @@ -139,7 +140,15 @@ func resourceNetboxIpamVlanRead(d *schema.ResourceData,

for _, resource := range resources.Payload.Results {
if strconv.FormatInt(resource.ID, 10) == d.Id() {
if err = d.Set("description", resource.Description); err != nil {
var description string

if resource.Description == "" {
description = " "
} else {
description = resource.Description
}

if err = d.Set("description", description); err != nil {
return err
}

Expand Down
11 changes: 10 additions & 1 deletion netbox/resource_netbox_tenancy_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func resourceNetboxTenancyTenant() *schema.Resource {
"description": {
Type: schema.TypeString,
Optional: true,
Default: " ",
ValidateFunc: validation.StringLenBetween(1, 100),
},
"tenant_group_id": {
Expand Down Expand Up @@ -128,7 +129,15 @@ func resourceNetboxTenancyTenantRead(d *schema.ResourceData,
return err
}

if err = d.Set("description", resource.Description); err != nil {
var description string

if resource.Description == "" {
description = " "
} else {
description = resource.Description
}

if err = d.Set("description", description); err != nil {
return err
}

Expand Down

0 comments on commit f340062

Please sign in to comment.