Full support on conan search queries with *

Summary

Conan search endpoint (api/conan/conan/v1/conans/search) should allow to search with *, we are can even have multiple * in one query. Right now, we don't support multiple stars and we only support the star if it is at the end of the package_name or the whole version is a star. Instead we should be ably to like query for any element in: package_name/version@user/channel

This is based on https://docs.conan.io/1/reference/commands/consumer/search.html and local test against jfrog/antifactory and local conan search.

Example of query supported now:

conan search 'package_n*/1.2.3@user/channel'
conan search 'package_n*'
conan search 'package_name/*@user/channel'
conan search 'package_name/*'

Example of query that should be supported

conan search 'package_n*/1.2.*@user/channel'
conan search 'p*kage_n*/1.2.3@user/channel'
conan search 'package_name/1.2.*@u*/cha*'
conan search 'package_name/1.2.*'
conan search 'package_name/1.2.3@us*'
conan search 'package_n*/1.2.*@user/channel'
conan search 'package_name/*/*@*/channel'

Example of query not supported by conan

Conan does not support wildcard over more than one section, except if the wildcard is the last char.

conan search 'package_name/*hannel'
conan search 'package_name/1.2.3@*hannel'

Steps to reproduce

Supposing you have a conan remote called "gitlab-local" pointing to your local gitlab project. If not, you can set it up following the documentations: https://docs.gitlab.com/ee/user/packages/conan_repository/#add-a-remote-for-your-project

Create a new conan package

mkdir searchTestpkg && cd searchTestpkg
conan new searchTest/1.2.3@gitlab-org+conan/stable --template=cmake_lib
conan create . gitlab-org+conan/stable

Upload the package

conan upload searchTest/1.2.3@gitlab-org+conan/stable -r gitlab-local --all

Search for the package

conan search s*chT*t/1.2.3@gitlab-org+conan/stable -r gitlab-local

What is the current bug behavior?

Conan returns

There are no packages matching the 's*chT*t/1.2.3@gitlab-org+conan/stable' pattern

What is the expected correct behavior?

Conan should returns:

Existing package recipes:

searchTest/1.2.3@gitlab-org+conan/stable

Results of GitLab environment info

Tested on master branch, commit 77770e7f

Possible fixes

Improve how the query is handled in app/services/packages/conan/search_service.rb:build_query. This requires to handle stars not only as last char, to support like query for version, user and channel and to probably add new indexes.

Edited by 🤖 GitLab Bot 🤖