Skip to content

Implement package metadata endpoint on the group level

Dzmitry (Dima) Meshcharakou requested to merge 299834-metadata-endpoint into master

What does this MR do and why?

This MR is part of #299834 (closed) and adds pull the packages using the group-level endpoint.

Screenshots or screen recordings

None

How to set up and validate locally

  1. Create a new npm package that will be installed using the group-level endpoint. For that in rails console run the following:

    def fixture_file_upload(*args, **kwargs)
      Rack::Test::UploadedFile.new(*args, **kwargs)
    end
    
    project = Project.first
    package = FactoryBot.create(:npm_package, project: project, name: 'hello_world')
    project.namespace_id # note it down, we'll be using it later
    project.namespace.path # node it down, we'll be using it later
    Feature.enable(:npm_group_level_endpoints, Namespace.find(project.namespace_id)) # enable the feature flag for selected namespace
  2. Create an empty npm package:

    $ mkdir npm-test-group-level && cd $_
    $ touch .tool-versions
    $ echo nodejs 18.16.0 > .tool-versions
    $ npm init
  3. Create .npmrc file in the same directory:

    $ touch .npmrc
    $ echo @scope:registry=http://gdk.test:3000/api/v4/group/<group_id>/-/packages/npm/ >> .npmrc
    $ echo //gdk.test:3000/api/v4/groups/<group_id>/-/packages/npm/:_authToken="${TOKEN}" >> .npmrc

    Note: Replace scope with namespace.path and <group_id> with namespace_id from the step 1.

  4. Install the package:

    $ TOKEN=<your_token> npm i hello_world

    Note: Replace <your_token> with a valid token.

    When everything goes well, the package gets installed 🎉

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 #299834 (closed)

Edited by Dzmitry (Dima) Meshcharakou

Merge request reports