Skip to content

Allow adding an Organization to an User Namespace

Rutger Wessels requested to merge 411832-usernamespace-assign-organization into master

What does this MR do and why?

As part of #411832, we want to validate that a Namespace always has an Organization assigned.

This MR makes the organization for user namespaces optional.

After this MR is merged, the next steps are:

  1. Create a few MR's that will take care of passing the organization_id from the controller (or api method) (often Current.organization but there are also other options)
  2. Release MR that adds a personal_namespace_require_org derisk feature flag
    1. If disabled, we do not require organization_id in call to user.assign_personal_namespace
    2. If enabled, we require organization_id in call to user.assign_personal_namespace
  3. Gradually roll out
  4. Clean up feature flag

Related issue #443494 (closed)

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.

How to set up and validate locally

In a Rails Console using gdk:

current_user = User.find_by_username('root')
my_org = Organizations::Organization.create!(name: "My Org", path: 'my-org')
user = Users::CreateService.new(current_user, {username: 'my-org-member', name: 'My Org Member', organization_id: my_org, password: 'my!%swasd3d', email: 'me@example.com'}).execute
user.save!
# Organization should be 'My Org
user.namespace.organization.name
Edited by Rutger Wessels

Merge request reports