Skip to content

Add search API endpoints that returns package references metadata

What does this MR do and why?

This MR adds support for full recipe search (or Conan package reference metadata search) functionality in GitLab's package registry, implementing both v1 and v2 API endpoints. The implementation follows the Conan v1 search specification and allows users to search for package recipes and retrieve detailed metadata about package references. The exact JSON answer is not documented, but we are copying the behavior of Jfrog artifactory.

The MR includes:

  1. A share endpoint for v1 endpoints (both instance-level and project-level) and v2 (project-level)
  2. A PackageReferenceInfoPresenter that handles metadata presentation
  3. Comprehensive test coverage
  4. Updated API documentation for both versions

This endpoint is also needed for the conan download command. This command will also be available after this MR.

References

-#208321 (closed)

Screenshots or screen recordings

no UI changes

How to set up and validate locally

1. Create a group, project, and personal access token if needed:

  • Create a new group in GitLab UI:

    1. Go to http://localhost:3000
    2. Click "New group"
    3. Set group name to "group1"
    4. Set visibility to "Private"
    5. Click "Create group"
  • Create a new project in GitLab UI:

    1. Go to http://localhost:3000/group1
    2. Click "New project"
    3. Choose "Create blank project"
    4. Set project name to "conan-test"
    5. Set visibility to "Private"
    6. Click "Create project"
  • Create a personal access token:

    1. Go to GitLab UI -> Settings -> Access Tokens
    2. Create a new token with api and read_api scopes

2. Configure Conan client for v1:

# Add GitLab as remotes
conan remote add gitlab-local-instance http://localhost:3000/api/v4/packages/conan
conan remote add gitlab-local-project http://localhost:3000/api/v4/projects/<project_id>/packages/conan

# Configure authentication
conan user -p <your_access_token> -r gitlab-local-instance <user>
conan user -p <your_access_token> -r gitlab-local-project <user>

3. Create and upload a test package:

# Create a new directory and enter it
mkdir testPackage && cd testPackage

# Create a new package using the cmake_lib template
# Using group1+conan-test project:
conan new testPackage/1.0@group1+conan-test/stable --template=cmake_lib

# Create package
conan create . group1+conan-test/stable

# Upload to GitLab
conan upload testPackage/1.0@group1+conan-test/stable -r gitlab-local-instance --all

# Note: If using a different project, replace group1+conan-test with your group+project name
# Example: conan new testPackage/1.0@<your-group>+<your-project>/stable --template=cmake_lib
#         conan create . <your-group>+<your-project>/stable
#         conan upload testPackage/1.0@<your-group>+<your-project>/stable -r gitlab-local-instance --all

4. Test the search endpoints:

a. Test instance-level v1 endpoint:

# Using Conan client
# Using conan-test project:
conan search testPackage/1.0@group1+conan-test/stable --remote=gitlab-local-instance

# Note: If using a different project, replace group1+conan-test with your group+project name
# Example: conan search testPackage/1.0@<your-group>+<your-project>/stable --remote=gitlab-local-instance

b. Test project-level v1 endpoint:

# Using Conan client
# Using conan-test project:
conan search testPackage/1.0@group1+conan-test/stable --remote=gitlab-local-project

# Note: If using a different project, replace group1+conan-test with your group+project name
# Example: conan search testPackage/1.0@<your-group>+<your-project>/stable --remote=gitlab-local-project

5. Verify the response format:

Existing packages for recipe testPackage/1.0@group1+conan-test/stable:

Existing recipe in remote 'gitlab-local-project':

    Package_ID: d8d8aba822aaa76849d2f1bafe4a2a62a9f83b74
        [options]
            fPIC: True
            shared: False
        [settings]
            arch: x86_64
            build_type: Release
            compiler: gcc
            compiler.libcxx: libstdc++
            compiler.version: 11
            os: Linux
        Outdated from recipe: False

Note: While the v2 endpoint implementation is included in this MR, it cannot be tested yet as the package upload functionality for v2 is not implemented. The v2 implementation will be fully testable once the package upload functionality is available in a future MR.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

/cc @mbo5be

Related to #208321 (closed)

Edited by Océane Legrand

Merge request reports

Loading