remove boilerplate code using CheckDeleted

This commit is contained in:
Guillaume Giamarchi 2015-02-19 23:31:19 +01:00 committed by Jon Perritt
parent 16a963313f
commit bdeca31731
3 changed files with 4 additions and 29 deletions

View File

@ -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 != "" {

View File

@ -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 != "" {

View File

@ -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)