Skip to content

Commit

Permalink
fix panic when setting empty iap block (#1232)
Browse files Browse the repository at this point in the history
  • Loading branch information
danawillow authored Mar 20, 2018
1 parent 7c12f53 commit ddfb7ef
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions google/resource_compute_backend_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,19 @@ func resourceComputeBackendServiceDelete(d *schema.ResourceData, meta interface{
}

func expandIap(configured []interface{}) *compute.BackendServiceIAP {
data := configured[0].(map[string]interface{})
iap := &compute.BackendServiceIAP{
Enabled: true,
Oauth2ClientId: data["oauth2_client_id"].(string),
Oauth2ClientSecret: data["oauth2_client_secret"].(string),
ForceSendFields: []string{"Enabled", "Oauth2ClientId", "Oauth2ClientSecret"},
if len(configured) == 0 {
return nil
}
if data, ok := configured[0].(map[string]interface{}); ok {
return &compute.BackendServiceIAP{
Enabled: true,
Oauth2ClientId: data["oauth2_client_id"].(string),
Oauth2ClientSecret: data["oauth2_client_secret"].(string),
ForceSendFields: []string{"Enabled", "Oauth2ClientId", "Oauth2ClientSecret"},
}
}

return iap
return nil
}

func flattenIap(iap *compute.BackendServiceIAP) []map[string]interface{} {
Expand Down

0 comments on commit ddfb7ef

Please sign in to comment.