Skip to content

Commit

Permalink
provider/azurerm: Adding an acceptance test for the ARM Loadbalancer
Browse files Browse the repository at this point in the history
  • Loading branch information
stack72 committed Oct 3, 2016
1 parent 76e08fc commit 966b7b3
Show file tree
Hide file tree
Showing 11 changed files with 807 additions and 735 deletions.
43 changes: 43 additions & 0 deletions builtin/providers/azurerm/loadbalancer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package azurerm

import (
"fmt"
"net/http"
"github.com/Azure/azure-sdk-for-go/arm/network"
)


func retrieveLoadbalancerById(loadBalancerId string, meta interface{}) (*network.LoadBalancer, bool, error) {
loadBalancerClient := meta.(*ArmClient).loadBalancerClient

id, err := parseAzureResourceID(loadBalancerId)
if err != nil {
return nil, false, err
}
name := id.Path["loadBalancers"]
resGroup := id.ResourceGroup

resp, err := loadBalancerClient.Get(resGroup, name, "")
if err != nil {
return nil, false, fmt.Errorf("Error making Read request on Azure Loadbalancer %s: %s", name, err)
}
if resp.StatusCode == http.StatusNotFound {
return nil, false, nil
}

return &resp, true, nil
}

func mergeLoadbalancerConfig(oldLb *network.LoadBalancer) network.LoadBalancer {
newLb := network.LoadBalancer{
Name: oldLb.Name,
Etag: oldLb.Etag,
Location: oldLb.Location,
}

if oldLb.Tags != nil {
newLb.Tags = oldLb.Tags
}

return newLb
}
15 changes: 11 additions & 4 deletions builtin/providers/azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,17 @@ func Provider() terraform.ResourceProvider {

ResourcesMap: map[string]*schema.Resource{
// These resources use the Azure ARM SDK
"azurerm_availability_set": resourceArmAvailabilitySet(),
"azurerm_cdn_endpoint": resourceArmCdnEndpoint(),
"azurerm_cdn_profile": resourceArmCdnProfile(),
"azurerm_loadbalancer": resourceArmLoadbalancer(),
"azurerm_availability_set": resourceArmAvailabilitySet(),
"azurerm_cdn_endpoint": resourceArmCdnEndpoint(),
"azurerm_cdn_profile": resourceArmCdnProfile(),

"azurerm_lb": resourceArmLoadbalancer(),
"azurerm_lb_frontend_ip_config": resourceArmLoadbalancerFrontEndIpConfig(),
"azurerm_lb_backend_address_pool": resourceArmLoadbalancerBackendAddressPool(),
"azurerm_lb_nat_rule": resourceArmLoadbalancerNatRule(),
"azurerm_lb_probe": resourceArmLoadbalancerProbe(),
"azurerm_lb_rule": resourceArmLoadbalancerRule(),

"azurerm_local_network_gateway": resourceArmLocalNetworkGateway(),
"azurerm_network_interface": resourceArmNetworkInterface(),
"azurerm_network_security_group": resourceArmNetworkSecurityGroup(),
Expand Down
Loading

0 comments on commit 966b7b3

Please sign in to comment.