Expose new properties on `/deploy_keys` API endpoint
What does this MR do and why?
Makes the following changes to the /deploy_keys
API endpoint:
- Add a
public
attribute that only return public deploy keys - Expose the
fingerprint
property - Expose the
projects_with_write_access
property
Related to #334874 (closed)
Currently the admin deploy keys table looks like this:
Data is passed to it from the deploy_keys_controller
and it only shows projects with write access via the projects_with_write_access
method.
We want to convert this table to GitLab UI so we can conform to the Pajamas designs system. We would like to use the /deploy_keys
API endpoint as the data source.
For context when the table is converted to GitLab UI it will look like this:
Database query
This is the query that I am seeing in the performance bar: deploy_keys_perf_bar_1635206602891.json
How to set up and validate locally
- Navigate to
/admin/deploy_keys
and create two deploy tokens. You can use https://8gwifi.org/sshfunctions.jsp to quickly generate a dummy public key. - Navigate to a project and then
Settings
->Repository
->Deploy keys
- Click the
Publicly accessible deploy keys
tab and clickEnable
next to each deploy key. - Navigate to the
Enabled deploy keys
tab. ClickEdit
next to each deploy key and check theGrant write permissions to this key
checkbox - Create a PAT in
/-/profile/personal_access_tokens
- Run
curl --header "PRIVATE-TOKEN: <your_access_token>" "http://<gdk-host>/api/v4/deploy_keys"
in your terminal - Click the
+
button in the performance bar and pastehttp://<gdk-host>/api/v4/deploy_keys
to see the database query
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Merge request reports
Activity
changed milestone to %14.5
assigned to @peterhegman
- A deleted user
added backend label
1 Message This merge request adds or changes documentation files. A review from the Technical Writing team before you merge is recommended. Reviews can happen after you merge. Documentation review
The following files require a review from a technical writer:
doc/api/deploy_keys.md
The review does not need to block merging this merge request. See the:
-
Metadata for the
*.md
files that you've changed. The first few lines of each*.md
file identify the stage and group most closely associated with your docs change. - The Technical Writer assigned for that stage and group.
- Documentation workflows for information on when to assign a merge request for review.
Reviewer roulette
Changes that require review have been detected!
Please refer to the table below for assigning reviewers and maintainers suggested by Danger in the specified category:
Category Reviewer Maintainer backend Laura Montemayor ( @lauraX
) (UTC-6, 1 hour ahead of@peterhegman
)Thong Kuah ( @tkuah
) (UTC+13, 20 hours ahead of@peterhegman
)To spread load more evenly across eligible reviewers, Danger has picked a candidate for each review slot, based on their timezone. Feel free to override these selections if you think someone else would be better-suited or use the GitLab Review Workload Dashboard to find other available reviewers.
To read more on how to use the reviewer roulette, please take a look at the Engineering workflow and code review guidelines. Please consider assigning a reviewer or maintainer who is a domain expert in the area of the merge request.
Once you've decided who will review this merge request, assign them as a reviewer! Danger does not automatically notify them for you.
If needed, you can retry the
danger-review
job that generated this comment.Generated by
Danger- Resolved by Mark Chao
I am a bit stumped on this backend change and was hoping you could help when you have some time. I am trying to expose
projects
on thedeploy_keys
REST API endpoint so I can use it to render the deploy keys table with Vue in #334874 (closed).I have it working but I am afraid exposing the
projects
relationship is causing a N+1 issue. I switchedDeployKey.all
to use thewith_projects
scope. I thought that would work since thewith_projects
scope usesinclude
but when I look at the SQL queries it seems like it isn't working. Any ideas on what I might be doing wrong?Here is the SQL query I am seeing: deploy_keys_perf_bar_1634252026106.json
Edited by Peter Hegman
@peterhegman, please can you answer the question: Should this have a feature flag? to help with code review for the Access group.This nudge was added by this triage-ops policy.
added 329 commits
-
bacd8972...2c25e5cc - 328 commits from branch
master
- 4191a09c - Expose new properties on `/deploy_keys` API endpoint
-
bacd8972...2c25e5cc - 328 commits from branch
added 1 commit
- f2d6609e - Expose new properties on `/deploy_keys` API endpoint
added 705 commits
-
f2d6609e...f8fac3f5 - 704 commits from branch
master
- 83cd2b23 - Expose new properties on `/deploy_keys` API endpoint
-
f2d6609e...f8fac3f5 - 704 commits from branch
added featureaddition label
added typefeature label
- A deleted user
added documentation label
added 1 commit
- 93d49c59 - Expose new properties on `/deploy_keys` API endpoint
requested review from @manojmj
removed review request for @manojmj
added 380 commits
-
93d49c59...c5e74a1d - 378 commits from branch
master
- a1c33dd3 - Expose new properties on `/deploy_keys` API endpoint
- 53c76c3f - Fix N+1 test failure on FOSS
-
93d49c59...c5e74a1d - 378 commits from branch
requested review from @ali-gitlab
marked the checklist item I have evaluated the MR acceptance checklist for this MR. as completed
- Resolved by Mark Chao
added 108 commits
-
53c76c3f...63f10d27 - 105 commits from branch
master
- e87dc830 - Expose new properties on `/deploy_keys` API endpoint
- 179ac1e5 - Fix N+1 test failure on FOSS
- f3d20462 - Switch to using lambda for conditional exposure
Toggle commit list-
53c76c3f...63f10d27 - 105 commits from branch
requested review from @lulalala and removed review request for @ali-gitlab
@ali-gitlab
, thanks for approving this merge request.This is the first time the merge request is approved. To ensure full test coverage, a new pipeline has been started.
For more info, please refer to the following links:
- Resolved by Peter Hegman
added 1 commit
- cebcde55 - Test number of returned projects with write access.
requested review from @eread
- Resolved by Peter Hegman
removed review request for @eread
added 471 commits
-
cebcde55...c9d4a405 - 467 commits from branch
master
- 36d4335b - Expose new properties on `/deploy_keys` API endpoint
- 573a028f - Fix N+1 test failure on FOSS
- 43be1987 - Switch to using lambda for conditional exposure
- ff8453ed - Update name used in example response to match docs style guide
Toggle commit list-
cebcde55...c9d4a405 - 467 commits from branch
requested review from @eread
removed review request for @eread
added Technical Writing docsfeature tw-weight3 twdoing labels
@lulalala looks like we have all required approvals now. Can you take another look at this when you have time?
enabled an automatic merge when the pipeline for f31a544c succeeds
mentioned in commit b420fea7
added workflowstaging-canary label and removed workflowready for development label
added workflowstaging label and removed workflowstaging-canary label
added workflowcanary label and removed workflowstaging label
added workflowproduction label and removed workflowcanary label
added releasedcandidate label
mentioned in issue gl-retrospectives/manage#106 (moved)
added releasedpublished label and removed releasedcandidate label