Fix protected tags with Deploy keys for FOSS

What does this MR do and why?

Contributes to #506642 (closed)

Problem

An attempt to add a Deploy key for FOSS version of GitLab returns an error "Failed ot update tag!".

There are two bugs causing that:

  1. for_role method returns only roles like Developer, No one without deploy keys. As a result, we don't mark Deploy keys as selected.
  2. Frontend does not correctly handle deploy key format in the request.

Solution

  • Remove for_role to correctly mark an existing deploy key as preselected.
  • Fix deploy key format when the key is selected

I applied similar solutions from Fix protected branches deploy key selection for... (!154884 - merged) and Add missing handler for protected branches Depl... (!149863 - merged) to resolve it.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
Screen_Recording_2024-11-29_at_15.02.26 Screen_Recording_2024-11-29_at_15.00.17

How to set up and validate locally

  1. Remove GitLab license
  2. Create a protected tag
  3. Add deploy key to the protected tag
  4. Select/remove the deploy key
  5. (without fix) You should see a Failed to update tag!
  6. (with fix) Deploy key can be added/removed without any problems
Edited by Vasilii Iakliushin

Merge request reports

Loading