Skip to content

Implement Conan API v2 Get endpoint, add feature flag v1 ping capability

  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA

This merge request adds a feature-flag to enable revisions capabilities and an initial endpoint definition for conan v2. This is part of the ongoing effort to enable Conan revisions support, as detailed in this issue.

Changes

  1. Feature Flag Implementation:
    • Added new feature flag conan_package_revisions_support to control new functionality
    • When enabled, this flag enables new V2 endpoints.
  2. V2 API Implementation:
    • Added new API::Conan::V2::ProjectPackages class to handle V2 endpoints in the future

Feature Flag Details

  • Name: conan_package_revisions_support
  • Default state: Disabled
  • Controls: Addition of 'revisions' capability in V1 ping response and availability of V2 endpoints

How to set up and validate locally

Since the backend is not implemented for the endpoint there is no need to setup a project and package for testing, the important part is to use the correct path and valid parameters.

  1. Enable feature flag in rails console (docs).

    For GDK, open rails console:

    gdk rails console

    To enable the flag run:

    Feature.enable(:conan_package_revisions_support)

    To check that it is set:

    Feature.enabled?(:conan_package_revisions_support)

    To disable the flag run:

    Feature.disable(:conan_package_revisions_support)
  2. Calling the ping v1 endpoint

    curl --request GET --url http://127.0.0.1:3000/api/v4/projects/9/packages/conan/v1/ping

    The respose will have status 200 OK and header X-Conan-Server-Capabilities: revisions. When the flag is off the header will not be there.

  3. Calling the v2 file endpoint

    curl --request GET --url 'http://127.0.0.1:3000/api/v4/projects/9/packages/conan/v2/conans/searchTest/1.3.4/gitlab-org+conan/stable/revisions/1f04d9667e60236fe5b0a05c506bb4a6/files/conanfile.py'

    When the flag is on the expected response is:

    • status: 404 Not Found
    • body: {"message": "Not supported"}

    When the flag is off the expected response is:

    • status: 404 Not Found
    • body: {"message": "'conan_package_revisions_support' feature flag is disabled"}
  4. Calling the v2 file endpoint with invalid parameters

    curl --request GET --url 'http://127.0.0.1:3000/api/v4/projects/9/packages/conan/v2/conans/searchTest/1.3.4/gitlab-org+conan/stable/revisions/1f04d9667e60236fe5b0a05c506bb4a6/files/conanfile.txt'

    When the flag is on the expected response is:

    • status: 400 Bad Request
    • body: {"error": "file_name does not have a valid value"}

    When the flag is off the expected response is:

    • status: 404 Not Found
    • body: {"message": "'conan_package_revisions_support' feature flag is disabled"}

Next Steps

  • Authentication-related changes for V2 endpoints will be addressed in a future merge request.
  • Further V2 endpoints and functionality will be implemented in subsequent merge requests.

References

cc @oceane_scania

Edited by Mariana Bocoi

Merge request reports

Loading