add variable and method comments

This commit is contained in:
Mike Mason
2023-07-17 19:02:55 +00:00
parent 2681b3d064
commit bc87fa7726
35 changed files with 157 additions and 16 deletions

View File

@@ -10,6 +10,8 @@ import (
"go.equinixmetal.net/infra9-metal-bridge/internal/permissions"
)
// syncMemberships determines the changes between what is wanted and what is live and executes on the differences.
// If skipDeletions is true, no deletes will be executed.
func (s *service) syncMemberships(ctx context.Context, relationships Relationships, skipDeletions bool) (int, int) {
if len(relationships.Memberships) == 0 {
return 0, 0
@@ -170,6 +172,10 @@ func (s *service) syncMemberships(ctx context.Context, relationships Relationshi
return rolesCreated + rolesDeleted, roleAssignments + roleUnassignments
}
// mapResourceWants processes the provided memberships and returns two maps.
// A Role Key is computed based on a sorted slice of actions for each role.
// The first map is of Role Key -> list of actions
// The second map is of Role Key -> Member ID -> true
func (s *service) mapResourceWants(memberships []ResourceMemberships) (map[string][]string, map[string]map[gidx.PrefixedID]bool) {
roleActionsKey := make(map[string]string)
@@ -196,6 +202,10 @@ func (s *service) mapResourceWants(memberships []ResourceMemberships) (map[strin
return wantRoles, wantAssignments
}
// mapResourceDetails fetches the provided ResourceID's live state and returns two maps and an error.
// A Role Key is computed based on a sorted slice of actions for each role.
// The first map is of Role Key -> Permissions Resource Role
// The second map is of Role Key -> Member ID -> true
func (s *service) mapResourceDetails(ctx context.Context, resourceID gidx.PrefixedID) (map[string]permissions.ResourceRole, map[string]map[gidx.PrefixedID]bool, error) {
roles := make(map[string]permissions.ResourceRole)
assignments := make(map[string]map[gidx.PrefixedID]bool)