Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix: Fix Crash in azurerm_container_group #5415

Merged
merged 2 commits into from
Jan 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ func resourceArmContainerGroupRead(d *schema.ResourceData, meta interface{}) err
}

if props := resp.ContainerGroupProperties; props != nil {
containerConfigs := flattenContainerGroupContainers(d, resp.Containers, props.IPAddress.Ports, props.Volumes)
containerConfigs := flattenContainerGroupContainers(d, resp.Containers, props.IPAddress, props.Volumes)
if err := d.Set("container", containerConfigs); err != nil {
return fmt.Errorf("Error setting `container`: %+v", err)
}
Expand Down Expand Up @@ -1104,7 +1104,7 @@ func flattenContainerImageRegistryCredentials(d *schema.ResourceData, input *[]c
return output
}

func flattenContainerGroupContainers(d *schema.ResourceData, containers *[]containerinstance.Container, containerGroupPorts *[]containerinstance.Port, containerGroupVolumes *[]containerinstance.Volume) []interface{} {
func flattenContainerGroupContainers(d *schema.ResourceData, containers *[]containerinstance.Container, ipAddress *containerinstance.IPAddress, containerGroupVolumes *[]containerinstance.Volume) []interface{} {
//map old container names to index so we can look up things up
nameIndexMap := map[string]int{}
for i, c := range d.Get("container").([]interface{}) {
Expand Down Expand Up @@ -1166,10 +1166,12 @@ func flattenContainerGroupContainers(d *schema.ResourceData, containers *[]conta
containerConfig["port"] = containerPort
// protocol isn't returned in container config, have to search in container group ports
protocol := ""
if containerGroupPorts != nil {
for _, cgPort := range *containerGroupPorts {
if *cgPort.Port == containerPort {
protocol = string(cgPort.Protocol)
if ipAddress != nil {
if containerGroupPorts := ipAddress.Ports; containerGroupPorts != nil {
for _, cgPort := range *containerGroupPorts {
if *cgPort.Port == containerPort {
protocol = string(cgPort.Protocol)
}
}
}
}
Expand Down