Skip to content

Commit

Permalink
Switching over to use the new helper
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Aug 1, 2017
1 parent 278ec58 commit fc5f83c
Show file tree
Hide file tree
Showing 50 changed files with 123 additions and 146 deletions.
3 changes: 1 addition & 2 deletions azurerm/express_route_circuit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package azurerm

import (
"fmt"
"net/http"

"github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/hashicorp/errwrap"
Expand Down Expand Up @@ -30,7 +29,7 @@ func retrieveErcByResourceId(resourceId string, meta interface{}) (erc *network.

resp, err := ercClient.Get(resGroup, name)
if err != nil {
if resp.StatusCode == http.StatusNotFound {
if responseWasNotFound(resp.Response) {
return nil, "", nil
}
return nil, "", errwrap.Wrapf(fmt.Sprintf("Error making Read request on Express Route Circuit %s: {{err}}", name), err)
Expand Down
1 change: 1 addition & 0 deletions azurerm/import_arm_eventhub_namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"fmt"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
Expand Down
3 changes: 2 additions & 1 deletion azurerm/import_arm_sql_elasticpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package azurerm

import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"testing"
)

func TestAccAzureRMSqlElasticPool_importBasic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_application_insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func resourceArmApplicationInsightsRead(d *schema.ResourceData, meta interface{}

resp, err := client.Get(resGroup, name)
if err != nil {
if resp.StatusCode == http.StatusNotFound {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
Expand Down
3 changes: 1 addition & 2 deletions azurerm/resource_arm_availability_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package azurerm
import (
"fmt"
"log"
"net/http"
"strings"

"github.com/Azure/azure-sdk-for-go/arm/compute"
Expand Down Expand Up @@ -117,7 +116,7 @@ func resourceArmAvailabilitySetRead(d *schema.ResourceData, meta interface{}) er

resp, err := client.Get(resGroup, name)
if err != nil {
if resp.StatusCode == http.StatusNotFound {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_cdn_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func resourceArmCdnEndpointRead(d *schema.ResourceData, meta interface{}) error
log.Printf("[INFO] Trying to find the AzureRM CDN Endpoint %s (Profile: %s, RG: %s)", name, profileName, resGroup)
resp, err := cdnEndpointsClient.Get(resGroup, profileName, name)
if err != nil {
if resp.StatusCode == http.StatusNotFound {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
Expand Down
4 changes: 1 addition & 3 deletions azurerm/resource_arm_cdn_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package azurerm
import (
"fmt"
"log"
"net/http"

"strings"

"github.com/Azure/azure-sdk-for-go/arm/cdn"
Expand Down Expand Up @@ -100,7 +98,7 @@ func resourceArmCdnProfileRead(d *schema.ResourceData, meta interface{}) error {

resp, err := cdnProfilesClient.Get(resGroup, name)
if err != nil {
if resp.StatusCode == http.StatusNotFound {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
Expand Down
9 changes: 5 additions & 4 deletions azurerm/resource_arm_container_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,13 @@ func resourceArmContainerRegistryRead(d *schema.ResourceData, meta interface{})

resp, err := client.Get(resourceGroup, name)
if err != nil {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}

return fmt.Errorf("Error making Read request on Azure Container Registry %s: %s", name, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}

d.Set("name", resp.Name)
d.Set("resource_group_name", resourceGroup)
Expand Down
9 changes: 5 additions & 4 deletions azurerm/resource_arm_container_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,13 @@ func resourceArmContainerServiceRead(d *schema.ResourceData, meta interface{}) e

resp, err := containerServiceClient.Get(resGroup, name)
if err != nil {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}

return fmt.Errorf("Error making Read request on Azure Container Service %s: %s", name, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}

d.Set("name", resp.Name)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
Expand Down
9 changes: 5 additions & 4 deletions azurerm/resource_arm_cosmos_db_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,13 @@ func resourceArmCosmosDBAccountRead(d *schema.ResourceData, meta interface{}) er

resp, err := client.Get(resGroup, name)
if err != nil {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}

return fmt.Errorf("Error making Read request on AzureRM CosmosDB Account '%s': %s", name, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}

d.Set("name", resp.Name)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
Expand Down
8 changes: 4 additions & 4 deletions azurerm/resource_arm_dns_a_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ func resourceArmDnsARecordRead(d *schema.ResourceData, meta interface{}) error {

resp, err := dnsClient.Get(resGroup, zoneName, name, dns.A)
if err != nil {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
return fmt.Errorf("Error reading DNS A record %s: %+v", name, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}

d.Set("name", name)
d.Set("resource_group_name", resGroup)
Expand Down
8 changes: 4 additions & 4 deletions azurerm/resource_arm_dns_aaaa_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ func resourceArmDnsAaaaRecordRead(d *schema.ResourceData, meta interface{}) erro

resp, err := dnsClient.Get(resGroup, zoneName, name, dns.AAAA)
if err != nil {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
return fmt.Errorf("Error reading DNS AAAA record %s: %v", name, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}

d.Set("name", name)
d.Set("resource_group_name", resGroup)
Expand Down
16 changes: 8 additions & 8 deletions azurerm/resource_arm_dns_cname_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,27 @@ func resourceArmDnsCNameRecordRead(d *schema.ResourceData, meta interface{}) err
name := id.Path["CNAME"]
zoneName := id.Path["dnszones"]

result, err := dnsClient.Get(resGroup, zoneName, name, dns.CNAME)
resp, err := dnsClient.Get(resGroup, zoneName, name, dns.CNAME)
if err != nil {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
return fmt.Errorf("Error reading DNS CNAME record %s: %+v", name, err)
}
if result.Response.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}

d.Set("name", name)
d.Set("resource_group_name", resGroup)
d.Set("zone_name", zoneName)
d.Set("ttl", result.TTL)
d.Set("ttl", resp.TTL)

if props := result.RecordSetProperties; props != nil {
if props := resp.RecordSetProperties; props != nil {
if record := props.CnameRecord; record != nil {
d.Set("record", record.Cname)
}
}

flattenAndSetTags(d, result.Metadata)
flattenAndSetTags(d, resp.Metadata)

return nil
}
Expand Down
8 changes: 4 additions & 4 deletions azurerm/resource_arm_dns_mx_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ func resourceArmDnsMxRecordRead(d *schema.ResourceData, meta interface{}) error

resp, err := client.Get(resGroup, zoneName, name, dns.MX)
if err != nil {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
return fmt.Errorf("Error reading DNS MX record %s: %v", name, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}

d.Set("name", name)
d.Set("resource_group_name", resGroup)
Expand Down
8 changes: 4 additions & 4 deletions azurerm/resource_arm_dns_ns_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ func resourceArmDnsNsRecordRead(d *schema.ResourceData, meta interface{}) error

resp, err := dnsClient.Get(resGroup, zoneName, name, dns.NS)
if err != nil {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
return fmt.Errorf("Error reading DNS NS record %s: %+v", name, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}

d.Set("name", name)
d.Set("resource_group_name", resGroup)
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_dns_ptr_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func resourceArmDnsPtrRecordRead(d *schema.ResourceData, meta interface{}) error

resp, err := dnsClient.Get(resGroup, zoneName, name, dns.PTR)
if err != nil {
if resp.StatusCode == http.StatusNotFound {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
Expand Down
8 changes: 4 additions & 4 deletions azurerm/resource_arm_dns_srv_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ func resourceArmDnsSrvRecordRead(d *schema.ResourceData, meta interface{}) error

resp, err := client.Get(resGroup, zoneName, name, dns.SRV)
if err != nil {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
return fmt.Errorf("Error reading DNS SRV record %s: %v", name, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}

d.Set("name", name)
d.Set("resource_group_name", resGroup)
Expand Down
8 changes: 4 additions & 4 deletions azurerm/resource_arm_dns_txt_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ func resourceArmDnsTxtRecordRead(d *schema.ResourceData, meta interface{}) error

resp, err := client.Get(resGroup, zoneName, name, dns.TXT)
if err != nil {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
return fmt.Errorf("Error reading DNS TXT record %s: %+v", name, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}

d.Set("name", name)
d.Set("resource_group_name", resGroup)
Expand Down
9 changes: 4 additions & 5 deletions azurerm/resource_arm_dns_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package azurerm

import (
"fmt"
"net/http"

"github.com/Azure/azure-sdk-for-go/arm/dns"
"github.com/hashicorp/terraform/helper/schema"
Expand Down Expand Up @@ -97,12 +96,12 @@ func resourceArmDnsZoneRead(d *schema.ResourceData, meta interface{}) error {

resp, err := zonesClient.Get(resGroup, name)
if err != nil {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
return fmt.Errorf("Error reading DNS zone %s (resource group %s): %+v", name, resGroup, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}

d.Set("name", name)
d.Set("resource_group_name", resGroup)
Expand Down
9 changes: 4 additions & 5 deletions azurerm/resource_arm_eventhub.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package azurerm
import (
"fmt"
"log"

"net/http"

"github.com/Azure/azure-sdk-for-go/arm/eventhub"
Expand Down Expand Up @@ -115,12 +114,12 @@ func resourceArmEventHubRead(d *schema.ResourceData, meta interface{}) error {

resp, err := eventhubClient.Get(resGroup, namespaceName, name)
if err != nil {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
return fmt.Errorf("Error making Read request on Azure EventHub %s: %s", name, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}

d.Set("name", resp.Name)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
Expand Down
9 changes: 4 additions & 5 deletions azurerm/resource_arm_eventhub_authorization_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package azurerm
import (
"fmt"
"log"

"net/http"

"github.com/Azure/azure-sdk-for-go/arm/eventhub"
Expand Down Expand Up @@ -144,12 +143,12 @@ func resourceArmEventHubAuthorizationRuleRead(d *schema.ResourceData, meta inter

resp, err := client.GetAuthorizationRule(resGroup, namespaceName, eventHubName, name)
if err != nil {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
return fmt.Errorf("Error making Read request on Azure EventHub Authorization Rule %s: %+v", name, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}

keysResp, err := client.ListKeys(resGroup, namespaceName, eventHubName, name)
if err != nil {
Expand Down
9 changes: 4 additions & 5 deletions azurerm/resource_arm_eventhub_consumer_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package azurerm
import (
"fmt"
"log"

"net/http"

"github.com/Azure/azure-sdk-for-go/arm/eventhub"
Expand Down Expand Up @@ -109,12 +108,12 @@ func resourceArmEventHubConsumerGroupRead(d *schema.ResourceData, meta interface

resp, err := eventhubClient.Get(resGroup, namespaceName, eventHubName, name)
if err != nil {
if responseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
return fmt.Errorf("Error making Read request on Azure EventHub Consumer Group %s: %+v", name, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}

d.Set("name", name)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
Expand Down
Loading

0 comments on commit fc5f83c

Please sign in to comment.