Skip to content

Use Project or Group organization for project/group bot namespace

What does this MR do and why?

As part of cell projects, we are working on introducing Organizations. All Namespaces will have an organization. This means we need to assign an Organization when we create a namespace.

This MR is part the effort of adding Organization to User Namespaces (also known as Personal Namespaces). User namespaces are created using the User.assign_personal_namespace method.

In a previous MR, we added a new optional Organization parameter to that method. And as a follow up, we need to update all code paths that are creating users to specify what Organization should be assigned.

This MR is focussing on creation of project and group bots. We don't use the Current.organization but derive the User Namespace for the bot from the Project organization or the Group organization.

  • Namespace for a project bot will be the organization of the project
  • Namespace for a group bot will be the organization of the group

Related to #443494 (closed)

Validate locally

Using GDK on this branch:

Preparation

  • Create an organization using rails console: org = Organizations::Organization.create!(name: "My Org", path: 'my-org')

For projects:

  • Assign the created organization to the project 'Flight': Project.find_by(name: 'Flight').update(organization: org)
  • Go to http://localhost:3000/flightjs/Flight/-/settings/access_tokens and create a new access token. this will create a new user behind the scenes
  • Assuming the access token was created succesfully, User.last should refer to the newly created user. So User.last.namespace.organization should show the organization created in the first step

For Groups:

  • Assign the created organization to the group 'Fligthjs': Group.find_by(name: 'Flightjs').update(organization: org)
  • Go to http://localhost:3000/groups/flightjs/-/settings/access_tokens and create a new access token. this will create a new user behind the scenes
  • Assuming the access token was created succesfully, User.last should refer to the newly created user. So User.last.namespace.organization should show the organization created in the first step
Edited by Rutger Wessels

Merge request reports