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:
-
for_rolemethod returns only roles likeDeveloper,No onewithout deploy keys. As a result, we don't mark Deploy keys as selected. - Frontend does not correctly handle deploy key format in the request.
Solution
- Remove
for_roleto 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
- Remove GitLab license
- Create a protected tag
- Add deploy key to the protected tag
- Select/remove the deploy key
- (without fix) You should see a
Failed to update tag! - (with fix) Deploy key can be added/removed without any problems