Skip to content

Commit

Permalink
Changes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Jan 7, 2019
1 parent 58832b7 commit bf430ce
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 84 deletions.
45 changes: 7 additions & 38 deletions azurerm/data_source_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package azurerm
import (
"fmt"

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

Expand All @@ -14,12 +15,13 @@ func dataSourceArmLoadBalancer() *schema.Resource {

Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.NoZeroValues,
},

"resource_group_name": resourceGroupNameSchema(),
"resource_group_name": resourceGroupNameForDataSourceSchema(),

"location": locationForDataSourceSchema(),

Expand Down Expand Up @@ -58,22 +60,6 @@ func dataSourceArmLoadBalancer() *schema.Resource {
Computed: true,
},

"load_balancer_rules": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},

"inbound_nat_rules": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},

"zones": zonesSchemaComputed(),
},
},
Expand Down Expand Up @@ -185,23 +171,6 @@ func flattenLoadBalancerDataSourceFrontendIpConfiguration(ipConfigs *[]network.F
if pip := props.PublicIPAddress; pip != nil {
ipConfig["public_ip_address_id"] = *pip.ID
}

loadBalancingRules := make([]interface{}, 0)
if rules := props.LoadBalancingRules; rules != nil {
for _, rule := range *rules {
loadBalancingRules = append(loadBalancingRules, *rule.ID)
}

}
ipConfig["load_balancer_rules"] = schema.NewSet(schema.HashString, loadBalancingRules)

inboundNatRules := make([]interface{}, 0)
if rules := props.InboundNatRules; rules != nil {
for _, rule := range *rules {
inboundNatRules = append(inboundNatRules, *rule.ID)
}
}
ipConfig["inbound_nat_rules"] = schema.NewSet(schema.HashString, inboundNatRules)
}

result = append(result, ipConfig)
Expand Down
40 changes: 0 additions & 40 deletions azurerm/data_source_loadbalancer_backend_address_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,6 @@ func dataSourceArmLoadBalancerBackendAddressPool() *schema.Resource {
Required: true,
ValidateFunc: azure.ValidateResourceID,
},

"backend_ip_configurations": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
},
Set: schema.HashString,
},

"load_balancing_rules": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
},
Set: schema.HashString,
},
},
}
}
Expand All @@ -67,25 +47,5 @@ func dataSourceArmLoadBalancerBackendAddressPoolRead(d *schema.ResourceData, met

d.SetId(*config.ID)

var backendIpConfigurations []string
var loadBalancingRules []string

if props := config.BackendAddressPoolPropertiesFormat; props != nil {
if configs := props.BackendIPConfigurations; configs != nil {
for _, backendConfig := range *configs {
backendIpConfigurations = append(backendIpConfigurations, *backendConfig.ID)
}
}

if rules := props.LoadBalancingRules; rules != nil {
for _, rule := range *rules {
loadBalancingRules = append(loadBalancingRules, *rule.ID)
}
}
}

d.Set("backend_ip_configurations", backendIpConfigurations)
d.Set("load_balancing_rules", loadBalancingRules)

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ func TestAccAzureRMDataSourceLoadBalancerBackEndAddressPool_basic(t *testing.T)
{
Config: testAccAzureRMDataSourceLoadBalancerBackEndAddressPool_basic(ri, location, addressPoolName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(dataSourceName, "backend_ip_configurations.#", "0"),
resource.TestCheckResourceAttr(dataSourceName, "load_balancing_rules.#", "0"),
resource.TestCheckResourceAttrSet(dataSourceName, "id"),
),
},
},
Expand Down
4 changes: 4 additions & 0 deletions website/docs/d/loadbalancer.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ The following attributes are exported:

* `location` - The Azure location where the Load Balancer exists.

* `private_ip_address` - The first private IP address assigned to the load balancer in `frontend_ip_configuration` blocks, if any.

* `private_ip_addresses` - The list of private IP address assigned to the load balancer in `frontend_ip_configuration` blocks, if any.

* `sku` - The SKU of the Load Balancer.

* `tags` - A mapping of tags assigned to the resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,3 @@ output "backend_address_pool_id" {
The following attributes are exported:

* `id` - The ID of the Backend Address Pool.

* `backend_ip_configurations` - The Backend IP Configurations associated with this Backend Address Pool.

* `load_balancing_rules` - The Load Balancing Rules associated with this Backend Address Pool.

0 comments on commit bf430ce

Please sign in to comment.