Skip to content

Add Importer User for imports user mapping

George Koltsov requested to merge georgekoltsov/user-mapping-import-user-2 into master

What does this MR do and why?

This MR adds Import user to a top level group with a new user type import_user. A new Gitlab::Import::ImportUserCreator is added to provision import_user to a root group so that it can be used when doing user mapping when we can't assign imported data to placeholder users.

It:

  1. Creates import user on a root group level for a portable provided (root group/subgroup/project)
  2. Returns existing import user if it's present
  3. Raises if provided portable doesn't have a root group
  4. Raises if user has no permission to admin_group root group
  5. Raises if import user failed to be persisted

Created import user doesn't appear in the list of billable users.

Mentions #443553 (closed)

[4] pry(main)> Gitlab::Import::ImportUserCreator.new(current_user: User.first, portable: Project.last).execute

=> #<User id:70 @import_user_group_9_dd85106ade8f8cdffb6dd93d0bb35e26>

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  1. Open rails console
  2. Run Gitlab::Import::ImportUserCreator.new(User.first, Group.find_by_full_path('mygroup')).execute with your user and group
  3. Observe import user is created
Edited by George Koltsov

Merge request reports