Skip to content

Commit

Permalink
Some more AzureStack changes for route table resource and datasource (h…
Browse files Browse the repository at this point in the history
…ashicorp#1807)

* backport azure stack route_table PR review comments

* More backported changes to route table resource & datasource
  • Loading branch information
katbyte authored and tombuildsstuff committed Aug 23, 2018
1 parent 25abf98 commit a4ca56f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 32 deletions.
10 changes: 6 additions & 4 deletions azurerm/data_source_route_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-04-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,8 +15,9 @@ func dataSourceArmRouteTable() *schema.Resource {

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

"resource_group_name": resourceGroupNameForDataSourceSchema(),
Expand Down Expand Up @@ -124,10 +126,10 @@ func flattenRouteTableDataSourceRoutes(input *[]network.Route) []interface{} {
return results
}

func flattenRouteTableDataSourceSubnets(input *[]network.Subnet) []string {
func flattenRouteTableDataSourceSubnets(subnets *[]network.Subnet) []string {
output := make([]string, 0)

if subnets := input; subnets != nil {
if subnets != nil {
for _, subnet := range *subnets {
output = append(output, *subnet.ID)
}
Expand Down
4 changes: 2 additions & 2 deletions azurerm/resource_arm_route_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ func flattenRouteTableRoutes(input *[]network.Route) []interface{} {
return results
}

func flattenRouteTableSubnets(input *[]network.Subnet) []string {
func flattenRouteTableSubnets(subnets *[]network.Subnet) []string {
output := []string{}

if subnets := input; subnets != nil {
if subnets != nil {
for _, subnet := range *subnets {
output = append(output, *subnet.ID)
}
Expand Down
52 changes: 26 additions & 26 deletions azurerm/resource_arm_route_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,19 +382,19 @@ resource "azurerm_route_table" "test" {
func testAccAzureRMRouteTable_singleRoute(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_route_table" "test" {
name = "acctestrt%d"
location = "${azurerm_resource_group.test.location}"
name = "acctestrt%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
route {
name = "route1"
name = "route1"
address_prefix = "10.1.0.0/16"
next_hop_type = "vnetlocal"
next_hop_type = "vnetlocal"
}
}
`, rInt, location, rInt)
Expand All @@ -403,41 +403,41 @@ resource "azurerm_route_table" "test" {
func testAccAzureRMRouteTable_singleRouteRemoved(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_route_table" "test" {
name = "acctestrt%d"
location = "${azurerm_resource_group.test.location}"
name = "acctestrt%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
route = []
route = []
}
`, rInt, location, rInt)
}

func testAccAzureRMRouteTable_multipleRoutes(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_route_table" "test" {
name = "acctestrt%d"
location = "${azurerm_resource_group.test.location}"
name = "acctestrt%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
route {
name = "route1"
name = "route1"
address_prefix = "10.1.0.0/16"
next_hop_type = "vnetlocal"
next_hop_type = "vnetlocal"
}
route {
name = "route2"
name = "route2"
address_prefix = "10.2.0.0/16"
next_hop_type = "vnetlocal"
next_hop_type = "vnetlocal"
}
}
`, rInt, location, rInt)
Expand All @@ -446,19 +446,19 @@ resource "azurerm_route_table" "test" {
func testAccAzureRMRouteTable_withTags(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_route_table" "test" {
name = "acctestrt%d"
location = "${azurerm_resource_group.test.location}"
name = "acctestrt%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
route {
name = "route1"
name = "route1"
address_prefix = "10.1.0.0/16"
next_hop_type = "vnetlocal"
next_hop_type = "vnetlocal"
}
tags {
Expand All @@ -472,19 +472,19 @@ resource "azurerm_route_table" "test" {
func testAccAzureRMRouteTable_withTagsUpdate(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_route_table" "test" {
name = "acctestrt%d"
location = "${azurerm_resource_group.test.location}"
name = "acctestrt%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
route {
name = "route1"
name = "route1"
address_prefix = "10.1.0.0/16"
next_hop_type = "vnetlocal"
next_hop_type = "vnetlocal"
}
tags {
Expand Down

0 comments on commit a4ca56f

Please sign in to comment.