Skip to content

Commit

Permalink
Sort IAM policy bindings by their role name to get simpler diffs as i…
Browse files Browse the repository at this point in the history
…t's what the API does
  • Loading branch information
pdecat committed Jun 19, 2019
1 parent 6135acd commit c54b2cd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions google/data_source_google_iam_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package google

import (
"encoding/json"
"sort"
"strconv"

"github.com/hashicorp/terraform/helper/hashcode"
Expand Down Expand Up @@ -103,6 +104,11 @@ func dataSourceGoogleIamPolicyRead(d *schema.ResourceData, meta interface{}) err
}
}

// Sort bindings by their role name to get simpler diffs as it's what the API does
sort.Slice(bindings, func(i, j int) bool {
return bindings[i].Role < bindings[j].Role
})

// Convert each audit_config into a cloudresourcemanager.AuditConfig
policy.AuditConfigs = expandAuditConfig(aset)

Expand Down

0 comments on commit c54b2cd

Please sign in to comment.