remove boilerplate code using CheckDeleted
This commit is contained in:
parent
16a963313f
commit
bdeca31731
|
@ -105,17 +105,9 @@ func resourceFWFirewallV1Read(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
firewall, err := firewalls.Get(networkingClient, d.Id()).Extract()
|
||||
if err != nil {
|
||||
httpError, ok := err.(*gophercloud.UnexpectedResponseCodeError)
|
||||
if !ok {
|
||||
return err
|
||||
}
|
||||
|
||||
if httpError.Actual == 404 {
|
||||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
if err != nil {
|
||||
return CheckDeleted(d, err, "LB pool")
|
||||
}
|
||||
|
||||
if t, exists := d.GetOk("name"); exists && t != "" {
|
||||
|
|
|
@ -119,15 +119,7 @@ func resourceFWPolicyV1Read(d *schema.ResourceData, meta interface{}) error {
|
|||
policy, err := policies.Get(networkingClient, d.Id()).Extract()
|
||||
|
||||
if err != nil {
|
||||
httpError, ok := err.(*gophercloud.UnexpectedResponseCodeError)
|
||||
if !ok {
|
||||
return err
|
||||
}
|
||||
if httpError.Actual == 404 {
|
||||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
return CheckDeleted(d, err, "LB pool")
|
||||
}
|
||||
|
||||
if t, exists := d.GetOk("name"); exists && t != "" {
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"log"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/rackspace/gophercloud"
|
||||
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies"
|
||||
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules"
|
||||
)
|
||||
|
@ -126,15 +125,7 @@ func resourceFWRuleV1Read(d *schema.ResourceData, meta interface{}) error {
|
|||
rule, err := rules.Get(networkingClient, d.Id()).Extract()
|
||||
|
||||
if err != nil {
|
||||
httpError, ok := err.(*gophercloud.UnexpectedResponseCodeError)
|
||||
if !ok {
|
||||
return err
|
||||
}
|
||||
if httpError.Actual == 404 {
|
||||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
return CheckDeleted(d, err, "LB pool")
|
||||
}
|
||||
|
||||
d.Set("protocol", rule.Protocol)
|
||||
|
|
Loading…
Reference in New Issue