Skip to content

Ease restriction for `:package_version` for the generic packages upload API

Summary

Ease restriction for :package_version regex validation in the generic packages upload API to allow the same format as $CI_COMMIT_TAG.

Improvements

While working on release-cli#54 (closed) I found that the generic packages API :package_version only accepts versions of the format 1.2.3. Values like v1.2.3 or 1.2.3-rc-1 fail when making the request to the API. This is because the Gitlab::Regex.generic_package_version_regex is defined as

def generic_package_version_regex
  /\A\d+\.\d+\.\d+\z/
end

By extending or even removing this validation we can allow the :package_name to be the same format as $CI_COMMIT_TAG. For example, if I want to upload files for my git tag v1.0.0-rc1, the URL would look like

/api/v4/projects/123/packages/generic/package_name/v1.0.0-rc1/file-number-one

This will improve the relationship between an uploaded file and a direct asset link that can be attached to a release.

Risks

  1. Sorting of package versions could be slower

Involved components

Optional: Intended side effects

Improve relationship of uploaded files and direct asset links attached to a release #36133 (closed)

Optional: Missing test coverage