func()

in deployment/hierarchy.go [103:127]


func (h *Hierarchy) PolicyRoleAssignments(ctx context.Context) (mapset.Set[PolicyRoleAssignment], error) {
	h.mu.RLock()
	defer h.mu.RUnlock()
	var errs *PolicyRoleAssignmentErrors
	res := mapset.NewThreadUnsafeSet[PolicyRoleAssignment]()
	// Get the policy assignments for each management group.
	for _, mg := range h.mgs {
		if err := mg.generatePolicyAssignmentAdditionalRoleAssignments(); err != nil {
			var thisErrs *PolicyRoleAssignmentErrors
			if errors.As(err, &thisErrs) {
				if errs == nil {
					errs = NewPolicyRoleAssignmentErrors()
				}
				errs.Add(thisErrs.Errors()...)
				continue
			}
			return nil, fmt.Errorf("Hierarchy.PolicyRoleAssignments: error generating additional role assignments for management group `%s`: %w", mg.id, err)
		}
		res = res.Union(mg.policyRoleAssignments)
	}
	if errs != nil {
		return res, errs
	}
	return res, nil
}