Skip to content

Adds field public_package to package details graphql

What does this MR do and why?

Adds a field public_package which indicates if there is public access to package. I've decided to call it public_package based on similar fields like public_jobs

Why

In #329253 (closed), we introduced a new option allow anyone to pull to the Package Registry.

With that option, users can configure private project to let anonymous users to download packages from that project.

The problem is that the package details have some instructions presented and those instructions are currently presenting that a token is mandatory.

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. rails c - Open the rails console

  2. p = Project.find(1) - Find a public project within GDK. Project id can be found on the project home page

  3. FactoryBot.create_list(:npm_package, 5, project: p, name: p.name) - Creates 5 npm packages

  4. Add this line if above fails during the creation of files

       def fixture_file_upload(*args, **kwargs)
         Rack::Test::UploadedFile.new(*args, **kwargs)
       end
  5. Packages::Package.last.id - Get the package id of the last created package

  6. Open the http://172.16.123.1:3000/-/graphql-explorer and query for one of the above created packages

    {
       package(id: "gid://gitlab/Packages::Package/<id>") {
         id
         publicPackage
       }
    }
  7. Visit Settings > General > Visibility, project features, permissions of the project in a new tab.

  8. If project is public, then publicPackage should return true

  9. Set project to private/internal, then publicPackage should return false

  10. Check the Allow anyone to pull from Package Registry checkbox, then publicPackage should return true

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

Edited by Rahul Chanila

Merge request reports