Add NuGet package tags support
What does this MR do?
This MR add package tags support in the GitLab nuget repository (https://docs.gitlab.com/ee/user/packages/nuget_repository/index.html).
There are two sides:
- Extract the package tags from the
.nuspec
file and save them - Expose them in the nuget API metadata endpoints and search endpoint.
Here is the definition of the package tags in the .nuspec
file:
A space-delimited list of tags and keywords that describe the package and aid discoverability of packages through search and filtering.
source: https://docs.microsoft.com/en-us/nuget/reference/nuspec#tags
For (1.), we will update the Packages::Nuget::MetadataExtractionService
which is responsible of reading the .nuspec
file and extract data from it. The service will do so for package tags and transform them into an array of Strings.
For the persistence part, we will re-use the Packages::Tag
model. Currently, this model is only created with the Packages::Npm::CreateTagService
. We can't use this service. First, it's one dedicated for NPM and not nuget. Second, it has a custom behavior where a tags are unique and thus adding an existing tag to a package version should delete the existing from the previous version. This is not what we want here for nuget. To solve this situation, we introduce a pretty generic Packages::CreateTagsService
. It will insert tags at once using a bulk insert.
Special note on persistence, users can upload multiple times a different archive for the same package name and version. The backend will simply append the files to the Packages::Package
and when a request asks for a file, the newest one is returned. For tags, we need to take care of them on each upload. This means that on each upload we have to sync the tags list. By sync
, we mean adding tags that are missing in the database and remove those that are not in the .nuspec
file.
For (2.), it's just a matter of updating the presenters to handle the tags and recreate a A space-delimited list of tags
.
See #42680 (closed)
Screenshots
Given the following .nuspec
file:
Tags are extracted and the package details page will look like this:
Here is one of the metadata API responding with tags:
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team