Skip to content

Add conan delete recipe_revision endpoint for v2

What does this MR do and why?

This MR will add the delete recipe_revision endpoint for Conan v2.

Changelog: added

The endpoint follows this format:

DELETE /api/v4/projects/:id/packages/conan/v2/conans/:package_name/package_version/:package_username/:package_channel/revisions/:recipe_revision

Notes:

  • Protected by the conan_package_revisions_support feature flag

References

How to set up and validate locally

To test we need 1 project where your token has access. In requests below, replace <project_id> with your corresponding project id.

  1. Switch the conan_package_revisions_support feature flag on.

    For GDK, open rails console (docs):

    gdk rails console

    Enable the feature flag:

    # Enable
    Feature.enable(:conan_package_revisions_support)
    
    # Verify
    Feature.enabled?(:conan_package_revisions_support)
  2. Make sure you have revisions enabled in your terminal

    Set the CONAN_REVISIONS_ENABLED envitonment variable to 1 to enable revisions for Conan 1.

    export CONAN_REVISIONS_ENABLED=1
  3. Have Conan 1 cli installed and configured with your project registry

    conan remote add gitlab https://gitlab.example.com/api/v4/projects/<project_id>/packages/conan
    conan user <user> -r gitlab -p <API Token>
  4. Create a package and upload two revisions

    In a test folder run:

    # Create a folder and a basic package
    mkdir delete_test && cd delete_test
    conan new delete_test/1.2.3@gitlab-org+conan/stable --template=cmake_lib
    
    # Build and upload the package for the first revision
    conan create . gitlab-org+conan/stable
    conan upload delete_test/1.2.3@gitlab-org+conan/stable -r gitlab
    
    # add a comment to the conanfile.py to force a new revision
    echo "# Test" >> conanfile.py
    
    # Build and upload the package for the second revision
    conan create . gitlab-org+conan/stable
    conan upload delete_test/1.2.3@gitlab-org+conan/stable -r gitlab

    Check package exists by running:

    conan search "delete_test*"  -r gitlab
  5. Check revisions on gitlab

    To check revisions in gitlab we assume you are testing using GitLab GDK

    Start rails console

    gdk rails console

    And run the following code to get a list of revisions for the package:

    Packages::Package.find_by(name: 'delete_test').conan_recipe_revisions.pluck(:revision)

    expected response:

    [<REVISION 1 ID>, <REVISION 2 ID>]
  6. Delete a package revision

    Run the following command to delete a revision.

    conan remove -f "delete_test/1.2.3@gitlab-org+conan/stable#<REVISION 1 ID>" -r gitlab

    Check revisions again in rails console by running the following code again:

    Packages::Package.find_by(name: 'delete_test').conan_recipe_revisions.pluck(:revision)

    expected response:

    [<REVISION 2 ID>]

    If you remove the second revision the package will be deleted as well as the revision:

    conan remove -f "delete_test/1.2.3@gitlab-org+conan/stable#<REVISION 2 ID>" -r gitlab

    When checking the package with the code below in rails console you should get nil

    Packages::Package.find_by(name: 'delete_test')

    You can check the package does not exist with the conan cli by running:

    conan search "delete_test*"  -r gitlab

    expected response

    There are no packages matching the 'delete_test*' pattern

/cc @oceane_scania

Related to #519741 (closed)

Edited by Mariana Bocoi

Merge request reports

Loading