Skip to content

Change the FF npm_allow_packages_in_multiple_projects to have an actor

What does this MR do and why?

There is the existing feature flag npm_allow_packages_in_multiple_projects that we tried to rollout a few times but no success (#391692 (comment 1557125807)). Now this feature flag makes it difficult to verify the code changes introduced in the block code that is behind the feature flag #425804 (comment 1608847525)

Thus MR changes the feature flag npm_allow_packages_in_multiple_projects to have a group actor. That will allow us to enable it for particular groups/namespaces without hurting gitlab.com

Screenshots or screen recordings

No.

How to set up and validate locally

Use the rails console to complete the steps.

  1. Create a new group with two projects.

    g = FactoryBot.create(:group, name: 'test-multi-packages')
    p1 = FactoryBot.create(:project, group: g)
    p2 = FactoryBot.create(:project, group: g)
  2. Create two npm packages.

    def fixture_file_upload(*args, **kwargs)
      Rack::Test::UploadedFile.new(*args, **kwargs)
    end
    
    package1 = FactoryBot.create(:npm_package, project: p1, name: '@test-multi-packages/package', version: '1.0.0')
    package2 = FactoryBot.create(:npm_package, project: p2, name: '@test-multi-packages/package', version: '2.0.0')
  3. Enable the FF npm_allow_packages_in_multiple_projects for a new group.

    Feature.enable(:npm_allow_packages_in_multiple_projects, g)

Now, create a request to get the @test-multi-packages/package metadata.

  1. Trigger a request with curl

    $ curl --header "PRIVATE-TOKEN: <PAT>" "http://gdk.test:3000/api/v4/groups/<group-id>/-/packages/npm/@test-multi-packages%2Fpackage"

    Make sure that the response contains two versions 1.0.0 and 2.0.0 of the @test-multi-packages/package

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #428628 (closed)

Edited by Dzmitry Meshcharakou

Merge request reports