Add conan delete recipe_revision endpoint for v2
-
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. As a benefit of being a GitLab Community Contributor, you receive complimentary access to GitLab Duo.
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_supportfeature 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.
-
Switch the
conan_package_revisions_supportfeature flag on.For GDK, open rails console (docs):
gdk rails consoleEnable the feature flag:
# Enable Feature.enable(:conan_package_revisions_support) # Verify Feature.enabled?(:conan_package_revisions_support) -
Make sure you have revisions enabled in your terminal
Set the
CONAN_REVISIONS_ENABLEDenvitonment variable to1to enable revisions for Conan 1.export CONAN_REVISIONS_ENABLED=1 -
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> -
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 gitlabCheck package exists by running:
conan search "delete_test*" -r gitlab -
Check revisions on gitlab
To check revisions in gitlab we assume you are testing using GitLab GDK
Start
rails consolegdk rails consoleAnd 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>] -
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 gitlabCheck revisions again in
rails consoleby 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 gitlabWhen checking the package with the code below in
rails consoleyou should getnilPackages::Package.find_by(name: 'delete_test')You can check the package does not exist with the
conan cliby running:conan search "delete_test*" -r gitlabexpected response
There are no packages matching the 'delete_test*' pattern
/cc @oceane_scania
Related to #519741 (closed)