Add versions array to package api response
What does this MR do?
This adds an array of versions
to the Package entity:
$ curl --header "PRIVATE-TOKEN: <redacted>" http://localhost:3001/api/v4/projects/1/packages/66
{
"id":66,
"name":"my/company/app/maven-app",
"version":"1.0.0-SNAPSHOT",
"package_type":"maven",
"_links":{
"web_path":"/gitlab-org/gitlab-test/-/packages/66",
"delete_api_path":"http://127.0.0.1:3001/api/v4/projects/1/packages/66"
},
"created_at":"2020-04-28T04:42:11.551Z",
"tags":[],
"versions":[
{
"id":67,
"version":"1.0.1-SNAPSHOT",
"created_at":"2020-04-28T04:42:11.573Z"
"pipeline": {...}
"tags":[...]
},
{
"id":68,
"version":"1.0.2-SNAPSHOT",
"created_at":"2020-04-29T04:42:11.573Z"
"pipeline": {...}
"tags":[...]
},
...
]
}
Database
Query for the versions
method:
EXPLAIN ANALYZE SELECT "packages_packages".*
FROM "packages_packages"
WHERE "packages_packages"."project_id" = 1
AND "packages_packages"."name" = 'my/company/app/maven-app'
AND "packages_packages"."version" != '1.0.0-SNAPSHOT'
AND "packages_packages"."package_type" = 1
ORDER BY "packages_packages"."version" ASC
QUERY PLAN
══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Index Scan using idx_packages_packages_on_project_id_name_version_package_type on packages_packages (cost=0.27..2.29 rows=1 width=68) (actual time=0.014..0.016 rows=4 loops=1)
Index Cond: ((project_id = 1) AND ((name)::text = 'my/company/app/maven-app'::text) AND (package_type = 1))
Filter: ((version)::text <> '1.0.0-SNAPSHOT'::text)
Rows Removed by Filter: 1
Planning Time: 0.310 ms
Execution Time: 0.054 ms
(6 rows)
Screenshots
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
Related #197962 (closed)
Edited by Steve Abrams