Skip to content

Commit

Permalink
Changes due to review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhijeet Gaiha committed Sep 14, 2017
1 parent e07edaf commit 6ab2d97
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions azurerm/resource_arm_container_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func resourceArmContainerGroup() *schema.Resource {
"ip_address": {
Type: schema.TypeString,
Computed: true,
ForceNew: true,
},

"container": {
Expand Down Expand Up @@ -213,7 +212,10 @@ func resourceArmContainerGroupRead(d *schema.ResourceData, meta interface{}) err
}

containerConfigs := flattenContainerGroupContainers(resp.Containers)
d.Set("container", containerConfigs)
err = d.Set("container", containerConfigs)
if err != nil {
return fmt.Errorf("Error setting `container`: %+v", err)
}

return nil
}
Expand Down Expand Up @@ -251,9 +253,12 @@ func flattenContainerGroupContainers(containers *[]containerinstance.Container)
containerConfig["name"] = *container.Name
containerConfig["image"] = *container.Image

resourceRequests := *(*container.Resources).Requests
containerConfig["cpu"] = *resourceRequests.CPU
containerConfig["memory"] = *resourceRequests.MemoryInGB
if resources := container.Resources; resources != nil {
if resourceRequests := resources.Requests; resourceRequests != nil {
containerConfig["cpu"] = *resourceRequests.CPU
containerConfig["memory"] = *resourceRequests.MemoryInGB
}
}

if len(*container.Ports) > 0 {
containerConfig["port"] = *(*container.Ports)[0].Port
Expand Down

0 comments on commit 6ab2d97

Please sign in to comment.