Allow adding an Organization to an User Namespace
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:
- Create a few MR's that will take care of passing the
organization_id
from the controller (or api method) (oftenCurrent.organization
but there are also other options) - Release MR that adds a
personal_namespace_require_org
derisk feature flag- If disabled, we do not require organization_id in call to
user.assign_personal_namespace
- If enabled, we require organization_id in call to
user.assign_personal_namespace
- If disabled, we do not require organization_id in call to
- Gradually roll out
- 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