Skip to content

Commit

Permalink
Merge pull request #305 from terraform-providers/np_check
Browse files Browse the repository at this point in the history
Verify null pointer check in policy read functions
  • Loading branch information
annakhm authored May 4, 2020
2 parents a1e139c + 265d42b commit b2821db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
12 changes: 6 additions & 6 deletions nsxt/resource_nsxt_policy_gateway_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ func resourceNsxtPolicyGatewayPolicyRead(d *schema.ResourceData, m interface{})
return handleReadError(d, "Gateway Policy", id, err)
}

d.Set("display_name", *obj.DisplayName)
d.Set("display_name", obj.DisplayName)
d.Set("description", obj.Description)
setPolicyTagsInSchema(d, obj.Tags)
d.Set("nsx_id", id)
d.Set("path", *obj.Path)
d.Set("path", obj.Path)
d.Set("domain", getDomainFromResourcePath(*obj.Path))
d.Set("category", *obj.Category)
d.Set("category", obj.Category)
d.Set("comments", obj.Comments)
d.Set("locked", *obj.Locked)
d.Set("sequence_number", *obj.SequenceNumber)
d.Set("stateful", *obj.Stateful)
d.Set("locked", obj.Locked)
d.Set("sequence_number", obj.SequenceNumber)
d.Set("stateful", obj.Stateful)
if obj.TcpStrict != nil {
// tcp_strict is dependant on stateful and maybe nil
d.Set("tcp_strict", *obj.TcpStrict)
Expand Down
12 changes: 9 additions & 3 deletions nsxt/resource_nsxt_policy_nat_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,20 @@ func resourceNsxtPolicyNATRuleRead(d *schema.ResourceData, m interface{}) error
d.Set("path", obj.Path)
d.Set("revision", obj.Revision)
d.Set("action", obj.Action)
d.Set("destination_networks", commaSeparatedStringToStringList(*obj.DestinationNetwork))
if obj.DestinationNetwork != nil {
d.Set("destination_networks", commaSeparatedStringToStringList(*obj.DestinationNetwork))
}
d.Set("enabled", obj.Enabled)
d.Set("firewall_match", obj.FirewallMatch)
d.Set("logging", obj.Logging)
d.Set("rule_priority", obj.SequenceNumber)
d.Set("service", obj.Service)
d.Set("source_networks", commaSeparatedStringToStringList(*obj.SourceNetwork))
d.Set("translated_networks", commaSeparatedStringToStringList(*obj.TranslatedNetwork))
if obj.SourceNetwork != nil {
d.Set("source_networks", commaSeparatedStringToStringList(*obj.SourceNetwork))
}
if obj.TranslatedNetwork != nil {
d.Set("translated_networks", commaSeparatedStringToStringList(*obj.TranslatedNetwork))
}
d.Set("translated_ports", obj.TranslatedPorts)
d.Set("scope", obj.Scope)

Expand Down

0 comments on commit b2821db

Please sign in to comment.