Commit Graph

8 Commits

Author SHA1 Message Date
Paul Stack 4ac7d0a6bb Merge pull request #8103 from BedeGaming/validation-helper
helper: create validation package to provide common validation functions
2016-10-07 13:42:29 +01:00
Paul Stack 250be11fdd Merge pull request #9073 from carinadigital/GH-9072
provider/azurerm: set resource_group_name on resource import
2016-10-07 13:29:08 +01:00
Andreas Kyrris 409ec88157 Fix failing acceptance tests by using case insensitive diff function.
Some resource fail due to resource_group_name always being stored as
lowercase. For those resources we add the case insensitive diff
function.
2016-10-03 15:46:34 +01:00
Andreas Kyrris bc3be270f1 Fix import of resource group name for azurerm_traffic_manager_profile. 2016-10-03 15:46:34 +01:00
Andreas Kyrris e5219ba56d Fixes behaviour when azurerm resources disappear.
Regressions were introduced when fixing
https://github.com/hashicorp/terraform/pull/8607 . Specifically when
resources in the statefile are deleted or missing in real life, then
terraform plan would exit with an error when it recieved a 404 not
found. The correct behaviour would be to show a plan with the offer to
create the missing resources.
2016-10-03 10:10:10 +01:00
stack72 392f634ff4
provider/azurerm: Reordering the checks after an Azure API Get
We are receiving suggestions of a panic as follows:

```
2016/09/01 07:21:55 [DEBUG] plugin: terraform: panic: runtime error: invalid memory address or nil pointer dereference
2016/09/01 07:21:55 [DEBUG] plugin: terraform: [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xa3170f]
2016/09/01 07:21:55 [DEBUG] plugin: terraform:
2016/09/01 07:21:55 [DEBUG] plugin: terraform: goroutine 114 [running]:
2016/09/01 07:21:55 [DEBUG] plugin: terraform: panic(0x27f4e60, 0xc4200100e0)
2016/09/01 07:21:55 [DEBUG] plugin: terraform: 	/opt/go/src/runtime/panic.go:500 +0x1a1
2016/09/01 07:21:55 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/builtin/providers/azurerm.resourceArmVirtualMachineRead(0xc4206d8060, 0x2995620, 0xc4204d0000, 0x0, 0x17)
2016/09/01 07:21:55 [DEBUG] plugin: terraform: 	/opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/azurerm/resource_arm_virtual_machine.go:488 +0x1ff
2016/09/01 07:21:55 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*Resource).Refresh(0xc420017a40, 0xc42040c780, 0x2995620, 0xc4204d0000, 0xc42019c990, 0x1, 0x0)
```

This is because the code is as follows:

```
resp, err := client.Get(resGroup, vnetName, name)
if resp.StatusCode == http.StatusNotFound {
	d.SetId("")
	return nil
}
if err != nil {
	return fmt.Errorf("Error making Read request on Azure virtual network peering %s: %s", name, err)
}
```

When a request throws an error, the response object isn't valid. Therefore, we need to flip that code to check the error first

```
resp, err := client.Get(resGroup, vnetName, name)
if err != nil {
	return fmt.Errorf("Error making Read request on Azure virtual network peering %s: %s", name, err)
}
if resp.StatusCode == http.StatusNotFound {
	d.SetId("")
	return nil
}
```
2016-09-01 15:31:42 +01:00
Peter McAtominey 012fd9825f provider/azurerm: refactor traffic_manager_ resources to use validation helpers
Updated:
	traffic_manager_profile
	traffic_manager_endpoint
2016-08-10 14:48:20 +01:00
Peter McAtominey cc18e4d7ca provider/azurerm: add traffic manager resources (#7826)
* provider/azurerm: vendor arm/trafficmanager package

* provider/azurerm: add azurerm_traffic_manager_profile resource

* provider/azurerm: add azurerm_traffic_manager_endpoint resource

* provider/azurerm: document traffic manager resources

* provider/azurerm: use short type argument for traffic manager endpoint

The resource now takes the short type for example azureEndpoints instead of the
long form Microsoft.Network/TrafficManagerProfiles/azureEndpoints.

```
TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMTrafficManagerEndpoint -timeout 120m
=== RUN   TestAccAzureRMTrafficManagerEndpoint_basic
--- PASS: TestAccAzureRMTrafficManagerEndpoint_basic (179.72s)
=== RUN   TestAccAzureRMTrafficManagerEndpoint_basicDisableExternal
--- PASS: TestAccAzureRMTrafficManagerEndpoint_basicDisableExternal (171.36s)
=== RUN   TestAccAzureRMTrafficManagerEndpoint_updateWeight
--- PASS: TestAccAzureRMTrafficManagerEndpoint_updateWeight (167.24s)
=== RUN   TestAccAzureRMTrafficManagerEndpoint_updatePriority
--- PASS: TestAccAzureRMTrafficManagerEndpoint_updatePriority (192.91s)
=== RUN   TestAccAzureRMTrafficManagerEndpoint_nestedEndpoints
--- PASS: TestAccAzureRMTrafficManagerEndpoint_nestedEndpoints (111.18s)
PASS
ok   github.com/hashicorp/terraform/builtin/providers/azurerm    822.534s
```

* provider/azurerm: remove unnecesary dereferences in traffic manager resources

```
TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMTrafficManager -timeout 120m
=== RUN   TestAccAzureRMTrafficManagerEndpoint_basic
--- PASS: TestAccAzureRMTrafficManagerEndpoint_basic (176.08s)
=== RUN   TestAccAzureRMTrafficManagerEndpoint_basicDisableExternal
--- PASS: TestAccAzureRMTrafficManagerEndpoint_basicDisableExternal (172.28s)
=== RUN   TestAccAzureRMTrafficManagerEndpoint_updateWeight
--- PASS: TestAccAzureRMTrafficManagerEndpoint_updateWeight (148.97s)
=== RUN   TestAccAzureRMTrafficManagerEndpoint_updatePriority
--- PASS: TestAccAzureRMTrafficManagerEndpoint_updatePriority (101.18s)
=== RUN   TestAccAzureRMTrafficManagerEndpoint_nestedEndpoints
--- PASS: TestAccAzureRMTrafficManagerEndpoint_nestedEndpoints (88.33s)
=== RUN   TestAccAzureRMTrafficManagerProfile_weighted
--- PASS: TestAccAzureRMTrafficManagerProfile_weighted (80.92s)
=== RUN   TestAccAzureRMTrafficManagerProfile_performance
--- PASS: TestAccAzureRMTrafficManagerProfile_performance (82.98s)
=== RUN   TestAccAzureRMTrafficManagerProfile_priority
--- PASS: TestAccAzureRMTrafficManagerProfile_priority (81.07s)
=== RUN   TestAccAzureRMTrafficManagerProfile_withTags
--- PASS: TestAccAzureRMTrafficManagerProfile_withTags (102.50s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	1034.458s
```
2016-07-31 23:46:15 +01:00