Skip to content

Commit

Permalink
Merge pull request #1750 from terraform-providers/errwrap_removal
Browse files Browse the repository at this point in the history
remove errwrap
  • Loading branch information
katbyte authored Aug 9, 2018
2 parents 92ebfeb + cbb4367 commit 249a790
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 45 deletions.
5 changes: 2 additions & 3 deletions azurerm/express_route_circuit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-04-01/network"
"github.com/hashicorp/errwrap"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand All @@ -26,15 +25,15 @@ func retrieveErcByResourceId(resourceId string, meta interface{}) (erc *network.

resGroup, name, err := extractResourceGroupAndErcName(resourceId)
if err != nil {
return nil, "", errwrap.Wrapf("Error Parsing Azure Resource ID - {{err}}", err)
return nil, "", fmt.Errorf("Error Parsing Azure Resource ID -: %+v", err)
}

resp, err := ercClient.Get(ctx, resGroup, name)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
return nil, "", nil
}
return nil, "", errwrap.Wrapf(fmt.Sprintf("Error making Read request on Express Route Circuit %s: {{err}}", name), err)
return nil, "", fmt.Errorf("Error making Read request on Express Route Circuit %s: %+v", name, err)
}

return &resp, resGroup, nil
Expand Down
3 changes: 1 addition & 2 deletions azurerm/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"strings"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-04-01/network"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
)
Expand All @@ -30,7 +29,7 @@ func retrieveLoadBalancerById(loadBalancerId string, meta interface{}) (*network

resGroup, name, err := resourceGroupAndLBNameFromId(loadBalancerId)
if err != nil {
return nil, false, errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err)
return nil, false, fmt.Errorf("Error Getting LoadBalancer Name and Group:: %+v", err)
}

resp, err := client.Get(ctx, resGroup, name, "")
Expand Down
9 changes: 4 additions & 5 deletions azurerm/resource_arm_application_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"strings"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-04-01/network"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
Expand Down Expand Up @@ -776,12 +775,12 @@ func resourceArmApplicationGatewayCreateUpdate(d *schema.ResourceData, meta inte
func resourceArmApplicationGatewayRead(d *schema.ResourceData, meta interface{}) error {
id, err := parseAzureResourceID(d.Id())
if err != nil {
return errwrap.Wrapf("Error parsing ApplicationGateway ID {{err}}", err)
return fmt.Errorf("Error parsing ApplicationGateway ID: %+v", err)
}

applicationGateway, exists, err := retrieveApplicationGatewayById(d.Id(), meta)
if err != nil {
return errwrap.Wrapf("Error Getting ApplicationGateway By ID {{err}}", err)
return fmt.Errorf("Error Getting ApplicationGateway By ID: %+v", err)
}
if !exists {
d.SetId("")
Expand Down Expand Up @@ -847,7 +846,7 @@ func resourceArmApplicationGatewayDelete(d *schema.ResourceData, meta interface{

id, err := parseAzureResourceID(d.Id())
if err != nil {
return errwrap.Wrapf("Error Parsing Azure Resource ID {{err}}", err)
return fmt.Errorf("Error Parsing Azure Resource ID: %+v", err)
}
resGroup := id.ResourceGroup
name := id.Path["applicationGateways"]
Expand Down Expand Up @@ -883,7 +882,7 @@ func retrieveApplicationGatewayById(applicationGatewayID string, meta interface{

resGroup, name, err := ApplicationGatewayResGroupAndNameFromID(applicationGatewayID)
if err != nil {
return nil, false, errwrap.Wrapf("Error Getting ApplicationGateway Name and Group: {{err}}", err)
return nil, false, fmt.Errorf("Error Getting ApplicationGateway Name and Group:: %+v", err)
}

resp, err := client.Get(ctx, resGroup, name)
Expand Down
3 changes: 1 addition & 2 deletions azurerm/resource_arm_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-04-01/network"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
Expand Down Expand Up @@ -261,7 +260,7 @@ func resourceArmLoadBalancerDelete(d *schema.ResourceData, meta interface{}) err

id, err := parseAzureResourceID(d.Id())
if err != nil {
return errwrap.Wrapf("Error Parsing Azure Resource ID {{err}}", err)
return fmt.Errorf("Error Parsing Azure Resource ID: %+v", err)
}
resGroup := id.ResourceGroup
name := id.Path["loadBalancers"]
Expand Down
5 changes: 2 additions & 3 deletions azurerm/resource_arm_loadbalancer_backend_address_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-04-01/network"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
Expand Down Expand Up @@ -75,7 +74,7 @@ func resourceArmLoadBalancerBackendAddressPoolCreate(d *schema.ResourceData, met

loadBalancer, exists, err := retrieveLoadBalancerById(loadBalancerID, meta)
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer By ID: %+v", err)
}
if !exists {
d.SetId("")
Expand Down Expand Up @@ -222,7 +221,7 @@ func resourceArmLoadBalancerBackendAddressPoolDelete(d *schema.ResourceData, met

resGroup, loadBalancerName, err := resourceGroupAndLBNameFromId(d.Get("loadbalancer_id").(string))
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer Name and Group:: %+v", err)
}

future, err := client.CreateOrUpdate(ctx, resGroup, loadBalancerName, *loadBalancer)
Expand Down
9 changes: 4 additions & 5 deletions azurerm/resource_arm_loadbalancer_nat_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-04-01/network"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
Expand Down Expand Up @@ -84,7 +83,7 @@ func resourceArmLoadBalancerNatPoolCreate(d *schema.ResourceData, meta interface

loadBalancer, exists, err := retrieveLoadBalancerById(loadBalancerID, meta)
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer By ID: %+v", err)
}
if !exists {
d.SetId("")
Expand All @@ -94,7 +93,7 @@ func resourceArmLoadBalancerNatPoolCreate(d *schema.ResourceData, meta interface

newNatPool, err := expandAzureRmLoadBalancerNatPool(d, loadBalancer)
if err != nil {
return errwrap.Wrapf("Error Expanding NAT Pool {{err}}", err)
return fmt.Errorf("Error Expanding NAT Pool: %+v", err)
}

natPools := append(*loadBalancer.LoadBalancerPropertiesFormat.InboundNatPools, *newNatPool)
Expand All @@ -110,7 +109,7 @@ func resourceArmLoadBalancerNatPoolCreate(d *schema.ResourceData, meta interface
loadBalancer.LoadBalancerPropertiesFormat.InboundNatPools = &natPools
resGroup, loadBalancerName, err := resourceGroupAndLBNameFromId(d.Get("loadbalancer_id").(string))
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer Name and Group:: %+v", err)
}

future, err := client.CreateOrUpdate(ctx, resGroup, loadBalancerName, *loadBalancer)
Expand Down Expand Up @@ -234,7 +233,7 @@ func resourceArmLoadBalancerNatPoolDelete(d *schema.ResourceData, meta interface

resGroup, loadBalancerName, err := resourceGroupAndLBNameFromId(d.Get("loadbalancer_id").(string))
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer Name and Group:: %+v", err)
}

future, err := client.CreateOrUpdate(ctx, resGroup, loadBalancerName, *loadBalancer)
Expand Down
5 changes: 2 additions & 3 deletions azurerm/resource_arm_loadbalancer_nat_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-04-01/network"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
Expand Down Expand Up @@ -105,7 +104,7 @@ func resourceArmLoadBalancerNatRuleCreateUpdate(d *schema.ResourceData, meta int

loadBalancer, exists, err := retrieveLoadBalancerById(loadBalancerID, meta)
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer By ID: %+v", err)
}
if !exists {
d.SetId("")
Expand All @@ -115,7 +114,7 @@ func resourceArmLoadBalancerNatRuleCreateUpdate(d *schema.ResourceData, meta int

newNatRule, err := expandAzureRmLoadBalancerNatRule(d, loadBalancer)
if err != nil {
return errwrap.Wrapf("Error Expanding NAT Rule {{err}}", err)
return fmt.Errorf("Error Expanding NAT Rule: %+v", err)
}

natRules := append(*loadBalancer.LoadBalancerPropertiesFormat.InboundNatRules, *newNatRule)
Expand Down
7 changes: 3 additions & 4 deletions azurerm/resource_arm_loadbalancer_probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-04-01/network"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
Expand Down Expand Up @@ -184,7 +183,7 @@ func resourceArmLoadBalancerProbeRead(d *schema.ResourceData, meta interface{})

loadBalancer, exists, err := retrieveLoadBalancerById(d.Get("loadbalancer_id").(string), meta)
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer By ID: %+v", err)
}
if !exists {
d.SetId("")
Expand Down Expand Up @@ -253,7 +252,7 @@ func resourceArmLoadBalancerProbeDelete(d *schema.ResourceData, meta interface{}

resGroup, loadBalancerName, err := resourceGroupAndLBNameFromId(d.Get("loadbalancer_id").(string))
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer Name and Group:: %+v", err)
}

future, err := client.CreateOrUpdate(ctx, resGroup, loadBalancerName, *loadBalancer)
Expand All @@ -268,7 +267,7 @@ func resourceArmLoadBalancerProbeDelete(d *schema.ResourceData, meta interface{}

read, err := client.Get(ctx, resGroup, loadBalancerName, "")
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer: %+v", err)
}
if read.ID == nil {
return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup)
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_loadbalancer_probe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestAccAzureRMLoadBalancerProbe_removal(t *testing.T) {
})
}

func TestAccAzureRMLoadBalancerProbe_update(t *testing.T) {
func maProbe_update(t *testing.T) {
var lb network.LoadBalancer
ri := acctest.RandInt()
probeName := fmt.Sprintf("probe-%d", ri)
Expand Down
19 changes: 9 additions & 10 deletions azurerm/resource_arm_loadbalancer_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"time"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-04-01/network"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
Expand Down Expand Up @@ -111,7 +110,7 @@ func resourceArmLoadBalancerRuleCreate(d *schema.ResourceData, meta interface{})

loadBalancer, exists, err := retrieveLoadBalancerById(loadBalancerID, meta)
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer By ID: %+v", err)
}
if !exists {
d.SetId("")
Expand All @@ -121,7 +120,7 @@ func resourceArmLoadBalancerRuleCreate(d *schema.ResourceData, meta interface{})

newLbRule, err := expandAzureRmLoadBalancerRule(d, loadBalancer)
if err != nil {
return errwrap.Wrapf("Error Exanding LoadBalancer Rule {{err}}", err)
return fmt.Errorf("Error Exanding LoadBalancer Rule: %+v", err)
}

lbRules := append(*loadBalancer.LoadBalancerPropertiesFormat.LoadBalancingRules, *newLbRule)
Expand All @@ -137,12 +136,12 @@ func resourceArmLoadBalancerRuleCreate(d *schema.ResourceData, meta interface{})
loadBalancer.LoadBalancerPropertiesFormat.LoadBalancingRules = &lbRules
resGroup, loadBalancerName, err := resourceGroupAndLBNameFromId(d.Get("loadbalancer_id").(string))
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer Name and Group:: %+v", err)
}

future, err := client.CreateOrUpdate(ctx, resGroup, loadBalancerName, *loadBalancer)
if err != nil {
return errwrap.Wrapf("Error Creating/Updating LoadBalancer {{err}}", err)
return fmt.Errorf("Error Creating/Updating LoadBalancer: %+v", err)
}

err = future.WaitForCompletionRef(ctx, client.Client)
Expand All @@ -152,7 +151,7 @@ func resourceArmLoadBalancerRuleCreate(d *schema.ResourceData, meta interface{})

read, err := client.Get(ctx, resGroup, loadBalancerName, "")
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer: %+v", err)
}
if read.ID == nil {
return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup)
Expand Down Expand Up @@ -194,7 +193,7 @@ func resourceArmLoadBalancerRuleRead(d *schema.ResourceData, meta interface{}) e

loadBalancer, exists, err := retrieveLoadBalancerById(d.Get("loadbalancer_id").(string), meta)
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer By ID: %+v", err)
}
if !exists {
d.SetId("")
Expand Down Expand Up @@ -259,7 +258,7 @@ func resourceArmLoadBalancerRuleDelete(d *schema.ResourceData, meta interface{})

loadBalancer, exists, err := retrieveLoadBalancerById(loadBalancerID, meta)
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer By ID: %+v", err)
}
if !exists {
d.SetId("")
Expand All @@ -277,7 +276,7 @@ func resourceArmLoadBalancerRuleDelete(d *schema.ResourceData, meta interface{})

resGroup, loadBalancerName, err := resourceGroupAndLBNameFromId(d.Get("loadbalancer_id").(string))
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer Name and Group: {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer Name and Group:: %+v", err)
}

future, err := client.CreateOrUpdate(ctx, resGroup, loadBalancerName, *loadBalancer)
Expand All @@ -292,7 +291,7 @@ func resourceArmLoadBalancerRuleDelete(d *schema.ResourceData, meta interface{})

read, err := client.Get(ctx, resGroup, loadBalancerName, "")
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer {{err}}", err)
return fmt.Errorf("Error Getting LoadBalancer: %+v", err)
}
if read.ID == nil {
return fmt.Errorf("Cannot read ID of LoadBalancer %q (resource group %s)", loadBalancerName, resGroup)
Expand Down
7 changes: 3 additions & 4 deletions azurerm/resource_arm_virtual_network_gateway_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"log"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-04-01/network"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
Expand Down Expand Up @@ -365,7 +364,7 @@ func getArmVirtualNetworkGatewayConnectionProperties(d *schema.ResourceData) (*n
virtualNetworkGatewayId := v.(string)
_, name, err := resourceGroupAndVirtualNetworkGatewayFromId(virtualNetworkGatewayId)
if err != nil {
return nil, errwrap.Wrapf("Error Getting VirtualNetworkGateway Name and Group: {{err}}", err)
return nil, fmt.Errorf("Error Getting VirtualNetworkGateway Name and Group:: %+v", err)
}

props.VirtualNetworkGateway1 = &network.VirtualNetworkGateway{
Expand Down Expand Up @@ -393,7 +392,7 @@ func getArmVirtualNetworkGatewayConnectionProperties(d *schema.ResourceData) (*n
peerVirtualNetworkGatewayId := v.(string)
_, name, err := resourceGroupAndVirtualNetworkGatewayFromId(peerVirtualNetworkGatewayId)
if err != nil {
return nil, errwrap.Wrapf("Error Getting VirtualNetworkGateway Name and Group: {{err}}", err)
return nil, fmt.Errorf("Error Getting VirtualNetworkGateway Name and Group:: %+v", err)
}

props.VirtualNetworkGateway2 = &network.VirtualNetworkGateway{
Expand All @@ -409,7 +408,7 @@ func getArmVirtualNetworkGatewayConnectionProperties(d *schema.ResourceData) (*n
localNetworkGatewayId := v.(string)
_, name, err := resourceGroupAndLocalNetworkGatewayFromId(localNetworkGatewayId)
if err != nil {
return nil, errwrap.Wrapf("Error Getting LocalNetworkGateway Name and Group: {{err}}", err)
return nil, fmt.Errorf("Error Getting LocalNetworkGateway Name and Group:: %+v", err)
}

props.LocalNetworkGateway2 = &network.LocalNetworkGateway{
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/hashicorp/errwrap/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,10 @@
"revisionTime": "2017-08-14T14:36:39Z"
},
{
"checksumSHA1": "cdOCt0Yb+hdErz8NAQqayxPmRsY=",
"checksumSHA1": "dVqCmA2mEDIDr8tEXu4gTaK9uPs=",
"path": "github.com/hashicorp/errwrap",
"revision": "7554cd9344cec97297fa6649b055a8c98c2a1e55"
"revision": "d6c0cd88035724dd42e0f335ae30161c20575ecc",
"revisionTime": "2018-07-15T04:49:06Z"
},
{
"checksumSHA1": "b8F628srIitj5p7Y130xc9k0QWs=",
Expand Down

0 comments on commit 249a790

Please sign in to comment.