Skip to content

Commit

Permalink
Change IAM binding to be authoritative
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisst authored and modular-magician committed Jan 4, 2019
1 parent 2dbae99 commit c88a3c1
Show file tree
Hide file tree
Showing 22 changed files with 922 additions and 1,178 deletions.
19 changes: 19 additions & 0 deletions google-beta/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,25 @@ func iamPolicyReadModifyWrite(updater ResourceIamUpdater, modify iamPolicyModify
return nil
}

// Takes a single binding and will either overwrite the same role in a list or append it to the end
func overwriteBinding(bindings []*cloudresourcemanager.Binding, overwrite *cloudresourcemanager.Binding) []*cloudresourcemanager.Binding {
var found bool

for i, b := range bindings {
if b.Role == overwrite.Role {
bindings[i] = overwrite
found = true
break
}
}

if !found {
bindings = append(bindings, overwrite)
}

return bindings
}

// Merge multiple Bindings such that Bindings with the same Role result in
// a single Binding with combined Members
func mergeBindings(bindings []*cloudresourcemanager.Binding) []*cloudresourcemanager.Binding {
Expand Down
2 changes: 1 addition & 1 deletion google-beta/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
// end beta-only products
GeneratedAppengineResourcesMap,
GeneratedComputeResourcesMap,
GeneratedCloudbuildResourcesMap,
GeneratedDnsResourcesMap,
GeneratedRedisResourcesMap,
GeneratedResourceManagerResourcesMap,
Expand All @@ -139,6 +138,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_billing_account_iam_binding": ResourceIamBindingWithImport(IamBillingAccountSchema, NewBillingAccountIamUpdater, BillingAccountIdParseFunc),
"google_billing_account_iam_member": ResourceIamMemberWithImport(IamBillingAccountSchema, NewBillingAccountIamUpdater, BillingAccountIdParseFunc),
"google_billing_account_iam_policy": ResourceIamPolicyWithImport(IamBillingAccountSchema, NewBillingAccountIamUpdater, BillingAccountIdParseFunc),
"google_cloudbuild_trigger": resourceCloudBuildTrigger(),
"google_cloudfunctions_function": resourceCloudFunctionsFunction(),
"google_cloudiot_registry": resourceCloudIoTRegistry(),
"google_composer_environment": resourceComposerEnvironment(),
Expand Down
21 changes: 0 additions & 21 deletions google-beta/provider_cloudbuild_gen.go

This file was deleted.

Loading

0 comments on commit c88a3c1

Please sign in to comment.