add variable and method comments
This commit is contained in:
@@ -9,13 +9,9 @@ import (
|
||||
"go.equinixmetal.net/infra9-metal-bridge/internal/permissions"
|
||||
)
|
||||
|
||||
type relationshipStats struct {
|
||||
parentCreated bool
|
||||
parentsDeleted int
|
||||
subjectRelationshipsCreated int
|
||||
subjectRelationshipsDeleted int
|
||||
}
|
||||
|
||||
// processRelationships determines the changes between what is wanted and what is live and executes on the differences.
|
||||
// Relationship creations use events.
|
||||
// Relationship deletions use the api, as delete events delete all related resources and not just the provided ones.
|
||||
func (s *service) processRelationships(ctx context.Context, eventType string, relationships Relationships) int {
|
||||
rlogger := s.logger.With("resource.id", relationships.Resource.PrefixedID())
|
||||
|
||||
@@ -161,6 +157,7 @@ func (s *service) processRelationships(ctx context.Context, eventType string, re
|
||||
return changes
|
||||
}
|
||||
|
||||
// mapRelationWants returns the parent relation if provided and a map of Subjects -> relation.
|
||||
func (s *service) mapRelationWants(relationships Relationships) (*Relation, map[gidx.PrefixedID]RelationshipType) {
|
||||
var wantParent *Relation
|
||||
|
||||
@@ -177,6 +174,9 @@ func (s *service) mapRelationWants(relationships Relationships) (*Relation, map[
|
||||
return wantParent, wantSubject
|
||||
}
|
||||
|
||||
// getRelationshipMap fetches the provided resources relationships, as the source resource and the destination subject.
|
||||
// Returned are two maps, the first maps Subject IDs -> Relationship
|
||||
// The second map, maps Resource IDs -> relationship
|
||||
func (s *service) getRelationshipMap(ctx context.Context, resource IDPrefixableResource, relatedObjectType ObjectType) (map[gidx.PrefixedID]RelationshipType, map[gidx.PrefixedID]RelationshipType, error) {
|
||||
liveResource, err := s.perms.ListResourceRelationships(ctx, resource.PrefixedID(), "")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user