Skip to content

Commit

Permalink
Fix nil panic with vault_identity_group_policies (#1245)
Browse files Browse the repository at this point in the history
  • Loading branch information
lawliet89 authored Dec 15, 2021
1 parent 9e1deea commit 4dd3cbd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion vault/resource_identity_group_policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ func identityGroupPoliciesRead(d *schema.ResourceData, meta interface{}) error {
} else {
userPolicies := d.Get("policies").(*schema.Set).List()
newPolicies := make([]string, 0)
apiPolicies := resp.Data["policies"].([]interface{})

var apiPolicies []interface{}
if val, ok := resp.Data["policies"]; ok && val != nil {
apiPolicies = val.([]interface{})
} else {
apiPolicies = make([]interface{}, 0)
}

for _, policy := range userPolicies {
if found, _ := util.SliceHasElement(apiPolicies, policy); found {
Expand Down

0 comments on commit 4dd3cbd

Please sign in to comment.