Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Dec 8, 2017
1 parent d340a00 commit e9a3ea6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions azurerm/data_source_virtual_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,29 @@ func dataSourceArmVirtualNetwork() *schema.Resource {
}

func dataSourceArmVnetRead(d *schema.ResourceData, meta interface{}) error {
vnetClient := meta.(*ArmClient).vnetClient
client := meta.(*ArmClient).vnetClient

resGroup := d.Get("resource_group_name").(string)
name := d.Get("name").(string)

resp, err := vnetClient.Get(resGroup, name, "")
resp, err := client.Get(resGroup, name, "")
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
return fmt.Errorf("Error making Read request on Azure virtual network %s: %+v", name, err)
return fmt.Errorf("Error making Read request on Azure virtual network %q (resource group %q): %+v", name, resGroup, err)
}
return err
}

d.SetId(*resp.ID)

if props := resp.VirtualNetworkPropertiesFormat; props != nil {
address_spaces := flattenVnetAddressPrefixes(props.AddressSpace.AddressPrefixes)
if err := d.Set("address_spaces", address_spaces); err != nil {
addressSpaces := flattenVnetAddressPrefixes(props.AddressSpace.AddressPrefixes)
if err := d.Set("address_spaces", addressSpaces); err != nil {
return err
}

dns_servers := flattenVnetAddressPrefixes(props.DhcpOptions.DNSServers)
if err := d.Set("dns_servers", dns_servers); err != nil {
dnsServers := flattenVnetAddressPrefixes(props.DhcpOptions.DNSServers)
if err := d.Set("dns_servers", dnsServers); err != nil {
return err
}

Expand All @@ -86,8 +86,8 @@ func dataSourceArmVnetRead(d *schema.ResourceData, meta interface{}) error {
return err
}

vnet_peerings := flattenVnetPeerings(props.VirtualNetworkPeerings)
if err := d.Set("vnet_peerings", vnet_peerings); err != nil {
vnetPeerings := flattenVnetPeerings(props.VirtualNetworkPeerings)
if err := d.Set("vnet_peerings", vnetPeerings); err != nil {
return err
}
}
Expand Down
4 changes: 2 additions & 2 deletions azurerm/data_source_virtual_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestAccDataSourceArmVirtualNetwork_peering(t *testing.T) {
dataSourceName := "data.azurerm_virtual_network.test"
ri := acctest.RandInt()

name_vnet_1 := fmt.Sprintf("acctestvnet-1-%d", ri)
virtualNetworkName := fmt.Sprintf("acctestvnet-1-%d", ri)
location := testLocation()

resource.Test(t, resource.TestCase{
Expand All @@ -49,7 +49,7 @@ func TestAccDataSourceArmVirtualNetwork_peering(t *testing.T) {
{
Config: testAccDataSourceArmVirtualNetwork_peeringWithDataSource(ri, location),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(dataSourceName, "name", name_vnet_1),
resource.TestCheckResourceAttr(dataSourceName, "name", virtualNetworkName),
resource.TestCheckResourceAttr(dataSourceName, "address_spaces.0", "10.0.1.0/24"),
resource.TestCheckResourceAttr(dataSourceName, "vnet_peerings.%", "1"),
),
Expand Down

0 comments on commit e9a3ea6

Please sign in to comment.