From 63bd3605e64b1853395e84f2f3e2adbd3881d94f Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 13 May 2019 16:41:57 +0200 Subject: [PATCH] r/network_profile: changes from code review --- azurerm/resource_arm_network_profile.go | 28 ++++++++++---------- azurerm/resource_arm_network_profile_test.go | 12 ++++----- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/azurerm/resource_arm_network_profile.go b/azurerm/resource_arm_network_profile.go index cdf7646f63da..9362f7d6e606 100644 --- a/azurerm/resource_arm_network_profile.go +++ b/azurerm/resource_arm_network_profile.go @@ -36,7 +36,7 @@ func resourceArmNetworkProfile() *schema.Resource { "resource_group_name": resourceGroupNameSchema(), - "container_network_interface_configuration": { + "container_network_interface": { Type: schema.TypeList, Required: true, MaxItems: 1, @@ -107,12 +107,12 @@ func resourceArmNetworkProfileCreateUpdate(d *schema.ResourceData, meta interfac location := azureRMNormalizeLocation(d.Get("location").(string)) tags := d.Get("tags").(map[string]interface{}) - cniConfigs, err := expandArmContainerNetworkInterfaceConfigurations(d) + cniConfigs, err := expandNetworkProfileContainerNetworkInterface(d) if err != nil { return fmt.Errorf("Error building list of Container Network Interface Configurations: %+v", err) } - subnetsToLock, vnetsToLock, err := extractVnetAndSubnetNames(d) + subnetsToLock, vnetsToLock, err := expandNetworkProfileVirtualNetworkSubnetNames(d) if err != nil { return fmt.Errorf("Error extracting names of Subnet and Virtual Network: %+v", err) } @@ -181,12 +181,12 @@ func resourceArmNetworkProfileRead(d *schema.ResourceData, meta interface{}) err } if props := profile.ProfilePropertiesFormat; props != nil { - cniConfigs := flattenArmContainerNetworkInterfaceConfigurations(props.ContainerNetworkInterfaceConfigurations) - if err := d.Set("container_network_interface_configuration", cniConfigs); err != nil { - return fmt.Errorf("Error setting `container_network_interface_configuration`: %+v", err) + cniConfigs := flattenNetworkProfileContainerNetworkInterface(props.ContainerNetworkInterfaceConfigurations) + if err := d.Set("container_network_interface", cniConfigs); err != nil { + return fmt.Errorf("Error setting `container_network_interface`: %+v", err) } - cniIDs := flattenArmContainerNetworkInterfaceIDs(props.ContainerNetworkInterfaces) + cniIDs := flattenNetworkProfileContainerNetworkInterfaceIDs(props.ContainerNetworkInterfaces) if err := d.Set("container_network_interface_ids", cniIDs); err != nil { return fmt.Errorf("Error setting `container_network_interface_ids`: %+v", err) } @@ -219,7 +219,7 @@ func resourceArmNetworkProfileDelete(d *schema.ResourceData, meta interface{}) e return fmt.Errorf("Error retrieving Network Profile %q (Resource Group %q): %+v", name, resourceGroup, err) } - subnetsToLock, vnetsToLock, err := extractVnetAndSubnetNames(d) + subnetsToLock, vnetsToLock, err := expandNetworkProfileVirtualNetworkSubnetNames(d) if err != nil { return fmt.Errorf("Error extracting names of Subnet and Virtual Network: %+v", err) } @@ -240,8 +240,8 @@ func resourceArmNetworkProfileDelete(d *schema.ResourceData, meta interface{}) e return err } -func expandArmContainerNetworkInterfaceConfigurations(d *schema.ResourceData) (*[]network.ContainerNetworkInterfaceConfiguration, error) { - cniConfigs := d.Get("container_network_interface_configuration").([]interface{}) +func expandNetworkProfileContainerNetworkInterface(d *schema.ResourceData) (*[]network.ContainerNetworkInterfaceConfiguration, error) { + cniConfigs := d.Get("container_network_interface").([]interface{}) retCNIConfigs := make([]network.ContainerNetworkInterfaceConfiguration, 0) for _, cniConfig := range cniConfigs { @@ -280,8 +280,8 @@ func expandArmContainerNetworkInterfaceConfigurations(d *schema.ResourceData) (* return &retCNIConfigs, nil } -func extractVnetAndSubnetNames(d *schema.ResourceData) (*[]string, *[]string, error) { - cniConfigs := d.Get("container_network_interface_configuration").([]interface{}) +func expandNetworkProfileVirtualNetworkSubnetNames(d *schema.ResourceData) (*[]string, *[]string, error) { + cniConfigs := d.Get("container_network_interface").([]interface{}) subnetNames := make([]string, 0) vnetNames := make([]string, 0) @@ -314,7 +314,7 @@ func extractVnetAndSubnetNames(d *schema.ResourceData) (*[]string, *[]string, er return &subnetNames, &vnetNames, nil } -func flattenArmContainerNetworkInterfaceConfigurations(input *[]network.ContainerNetworkInterfaceConfiguration) []interface{} { +func flattenNetworkProfileContainerNetworkInterface(input *[]network.ContainerNetworkInterfaceConfiguration) []interface{} { retCNIConfigs := make([]interface{}, 0) if input == nil { return retCNIConfigs @@ -353,7 +353,7 @@ func flattenArmContainerNetworkInterfaceConfigurations(input *[]network.Containe return retCNIConfigs } -func flattenArmContainerNetworkInterfaceIDs(input *[]network.ContainerNetworkInterface) []string { +func flattenNetworkProfileContainerNetworkInterfaceIDs(input *[]network.ContainerNetworkInterface) []string { retCNIs := make([]string, 0) if input == nil { return retCNIs diff --git a/azurerm/resource_arm_network_profile_test.go b/azurerm/resource_arm_network_profile_test.go index 681fecb864b0..f6621c2e5df6 100644 --- a/azurerm/resource_arm_network_profile_test.go +++ b/azurerm/resource_arm_network_profile_test.go @@ -238,7 +238,7 @@ resource "azurerm_network_profile" "test" { location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" - container_network_interface_configuration { + container_network_interface { name = "acctesteth-%d" ip_configuration { @@ -260,11 +260,11 @@ resource "azurerm_network_profile" "import" { location = "${azurerm_network_profile.test.location}" resource_group_name = "${azurerm_network_profile.test.resource_group_name}" - container_network_interface_configuration { - name = "${azurerm_network_profile.test.container_network_interface_configuration.0.name}" + container_network_interface { + name = "${azurerm_network_profile.test.container_network_interface.0.name}" ip_configuration { - name = "${azurerm_network_profile.test.container_network_interface_configuration.0.ip_configuration.0.name}" + name = "${azurerm_network_profile.test.container_network_interface.0.ip_configuration.0.name}" subnet_id = "${azurerm_subnet.test.id}" } } @@ -307,7 +307,7 @@ resource "azurerm_network_profile" "test" { location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" - container_network_interface_configuration { + container_network_interface { name = "acctesteth-%d" ip_configuration { @@ -359,7 +359,7 @@ resource "azurerm_network_profile" "test" { location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" - container_network_interface_configuration { + container_network_interface { name = "acctesteth-%d" ip_configuration {