Skip to content

Commit

Permalink
r/network_profile: changes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed May 13, 2019
1 parent d7c8ce2 commit 63bd360
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
28 changes: 14 additions & 14 deletions azurerm/resource_arm_network_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions azurerm/resource_arm_network_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}"
}
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 63bd360

Please sign in to comment.