sudo87 commented on code in PR #340:
URL:
https://github.com/apache/cloudstack-terraform-provider/pull/340#discussion_r4003143110
##########
cloudstack/resource_cloudstack_role_permission.go:
##########
@@ -242,28 +244,13 @@ func reconcileCloudStackRolePermissions(d
*schema.ResourceData, meta interface{}
rolePermissionsByID[rp.Id] = rp
}
- used := make(map[string]bool)
- deleted := make(map[string]bool)
managedIDs := make([]string, 0)
managedIDSet := make(map[string]bool)
+ desiredPermissions :=
rolePermissionSpecs(d.Get("permission").([]interface{}))
+ matchedPermissions := matchCloudStackRolePermissions(rolePermissions,
desiredPermissions)
- for _, desired := range
rolePermissionSpecs(d.Get("permission").([]interface{})) {
- rp := rolePermissionsByID[desired.ID]
- if rp != nil && (rp.Rule != desired.Rule || rp.Description !=
desired.Description) {
- if exactMatch :=
findMatchingRolePermission(rolePermissions, desired, used); exactMatch != nil {
- rp = exactMatch
- } else {
- if err := deleteCloudStackRolePermission(cs,
rp.Id); err != nil {
- return err
- }
- deleted[rp.Id] = true
- used[rp.Id] = true
- rp = nil
- }
- } else if rp == nil {
- rp = findMatchingRolePermission(rolePermissions,
desired, used)
- }
-
+ for i, desired := range desiredPermissions {
+ rp := matchedPermissions[i]
if rp == nil {
rp, err = createCloudStackRolePermission(cs, roleID,
desired)
if err != nil {
Review Comment:
@bddvlpr could you please take a look at copilot's comment?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]