Single method for determining ownership of groups and projects

I'm noticing a fair few owner? has_owner? is_owner? etc type methods being defined inconsistently on Project, ProjectTeam, Group, etc. Many of these ownership methods hinge on the owners method.

For example: Group has an association owners. Because until this point Projects didn't have Owners, the owners method in Project Team defers to the parent group. But only the parent group's direct owners.

Because Ownership is such a critical part of GitLab, we need to step slowly to cover the cases, use plenty of feature flags to we move away from inconsistent methods to a unified, inherited-first approach.

Strategy

  1. Create a module Ownership (or similar) to hold ownership methods
  2. Add a method has_ownership? (or something very similar) which has the following structure:
def users_with_owner_role(relationship:)
  # relationship can be: direct_only, direct_or_inherited, direct_or_inherited_or_shared

  # code stuff here
end
  1. We can then replace calls to groups of users with owner relationship with this method using feature flags to ensure no bugs are introduced.
  2. Later we can add other methods for other roles.

Availability and Testing

  • Please run e2e:package-and-test job manually on all related MRs. If a feature flag definition file is updated in the MR, then this job should be triggered automatically and will include ee:instance-parallel and ee:instance-parallel-ff-inverse jobs to test changes with the feature flag both on and off. More info can be found in the docs here.
  • Feel free to reach out to @vburton if there are any questions on QA failures
Edited by Valerie Burton