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

Add check for type conversion and deference. #2742

Merged
merged 2 commits into from
Jan 23, 2019
Merged
Changes from 1 commit
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
22 changes: 16 additions & 6 deletions azurerm/resource_arm_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,15 @@ func expandSubnetServiceEndpoints(d *schema.ResourceData) []network.ServiceEndpo
serviceEndpoints := d.Get("service_endpoints").([]interface{})
enpoints := make([]network.ServiceEndpointPropertiesFormat, 0)

for _, serviceEndpointsRaw := range serviceEndpoints {
data := serviceEndpointsRaw.(string)
for _, svcEndpointRaw := range serviceEndpoints {
if svcEndpointRaw == nil {
metacpp marked this conversation as resolved.
Show resolved Hide resolved
continue
}

svc := svcEndpointRaw.(string)

endpoint := network.ServiceEndpointPropertiesFormat{
Service: &data,
Service: &svc,
}

enpoints = append(enpoints, endpoint)
Expand All @@ -335,10 +339,16 @@ func expandSubnetServiceEndpoints(d *schema.ResourceData) []network.ServiceEndpo
func flattenSubnetServiceEndpoints(serviceEndpoints *[]network.ServiceEndpointPropertiesFormat) []string {
endpoints := make([]string, 0)

if serviceEndpoints != nil {
for _, endpoint := range *serviceEndpoints {
endpoints = append(endpoints, *endpoint.Service)
if serviceEndpoints == nil {
return endpoints
}

for _, endpoint := range *serviceEndpoints {
if endpoint.Service == nil {
metacpp marked this conversation as resolved.
Show resolved Hide resolved
continue
}

endpoints = append(endpoints, *endpoint.Service)
}

return endpoints
Expand Down