From a4ca56f4e0433c3763ad4b67941268359d7ee7e8 Mon Sep 17 00:00:00 2001 From: kt Date: Thu, 23 Aug 2018 01:38:03 -0700 Subject: [PATCH] Some more AzureStack changes for route table resource and datasource (#1807) * backport azure stack route_table PR review comments * More backported changes to route table resource & datasource --- azurerm/data_source_route_table.go | 10 +++-- azurerm/resource_arm_route_table.go | 4 +- azurerm/resource_arm_route_table_test.go | 52 ++++++++++++------------ 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/azurerm/data_source_route_table.go b/azurerm/data_source_route_table.go index 08d6c18af18c..3dc249079d51 100644 --- a/azurerm/data_source_route_table.go +++ b/azurerm/data_source_route_table.go @@ -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" ) @@ -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(), @@ -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) } diff --git a/azurerm/resource_arm_route_table.go b/azurerm/resource_arm_route_table.go index 370187af7b17..773193a47a0f 100644 --- a/azurerm/resource_arm_route_table.go +++ b/azurerm/resource_arm_route_table.go @@ -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) } diff --git a/azurerm/resource_arm_route_table_test.go b/azurerm/resource_arm_route_table_test.go index f014f9cfb7e5..60e174970aa8 100644 --- a/azurerm/resource_arm_route_table_test.go +++ b/azurerm/resource_arm_route_table_test.go @@ -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) @@ -403,15 +403,15 @@ 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) } @@ -419,25 +419,25 @@ resource "azurerm_route_table" "test" { 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) @@ -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 { @@ -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 {