Commit 33600264 authored by James Lopez's avatar James Lopez

Merge branch 'expose_project_container_registry_url' into 'master'

Expose container_registry_image_prefix to project API

See merge request gitlab-org/gitlab!54090
parents 08187218 6f55d68c
---
title: Expose container_registry_image_prefix to project API
merge_request: 54090
author: Mathieu Parent
type: added
......@@ -179,6 +179,7 @@ When the user is authenticated and `simple` is not set this returns something li
"packages_size": 0,
"snippets_size": 0
},
"container_registry_image_prefix": "registry.example.com/diaspora/diaspora-client",
"_links": {
"self": "http://example.com/api/v4/projects",
"issues": "http://example.com/api/v4/projects/1/issues",
......@@ -284,6 +285,7 @@ When the user is authenticated and `simple` is not set this returns something li
"packages_size": 0,
"snippets_size": 0
},
"container_registry_image_prefix": "registry.example.com/brightbox/puppet",
"_links": {
"self": "http://example.com/api/v4/projects",
"issues": "http://example.com/api/v4/projects/1/issues",
......@@ -439,6 +441,7 @@ GET /users/:user_id/projects
"packages_size": 0,
"snippets_size": 0
},
"container_registry_image_prefix": "registry.example.com/diaspora/diaspora-client",
"_links": {
"self": "http://example.com/api/v4/projects",
"issues": "http://example.com/api/v4/projects/1/issues",
......@@ -544,6 +547,7 @@ GET /users/:user_id/projects
"packages_size": 0,
"snippets_size": 0
},
"container_registry_image_prefix": "registry.example.com/brightbox/puppet",
"_links": {
"self": "http://example.com/api/v4/projects",
"issues": "http://example.com/api/v4/projects/1/issues",
......@@ -658,6 +662,7 @@ Example response:
"lfs_objects_size": 0,
"job_artifacts_size": 0
},
"container_registry_image_prefix": "registry.example.com/diaspora/diaspora-client",
"_links": {
"self": "http://example.com/api/v4/projects",
"issues": "http://example.com/api/v4/projects/1/issues",
......@@ -758,6 +763,7 @@ Example response:
"lfs_objects_size": 0,
"job_artifacts_size": 0
},
"container_registry_image_prefix": "registry.example.com/brightbox/puppet",
"_links": {
"self": "http://example.com/api/v4/projects",
"issues": "http://example.com/api/v4/projects/1/issues",
......@@ -921,6 +927,7 @@ GET /projects/:id
"packages_size": 0,
"snippets_size": 0
},
"container_registry_image_prefix": "registry.example.com/diaspora/diaspora-client",
"_links": {
"self": "http://example.com/api/v4/projects",
"issues": "http://example.com/api/v4/projects/1/issues",
......@@ -1373,6 +1380,7 @@ Example responses:
"merge_method": "merge",
"autoclose_referenced_issues": true,
"suggestion_commit_message": null,
"container_registry_image_prefix": "registry.example.com/diaspora/diaspora-project-site",
"_links": {
"self": "http://example.com/api/v4/projects",
"issues": "http://example.com/api/v4/projects/1/issues",
......@@ -1467,6 +1475,7 @@ Example response:
"merge_method": "merge",
"autoclose_referenced_issues": true,
"suggestion_commit_message": null,
"container_registry_image_prefix": "registry.example.com/diaspora/diaspora-project-site",
"_links": {
"self": "http://example.com/api/v4/projects",
"issues": "http://example.com/api/v4/projects/1/issues",
......@@ -1559,6 +1568,7 @@ Example response:
"merge_method": "merge",
"autoclose_referenced_issues": true,
"suggestion_commit_message": null,
"container_registry_image_prefix": "registry.example.com/diaspora/diaspora-project-site",
"_links": {
"self": "http://example.com/api/v4/projects",
"issues": "http://example.com/api/v4/projects/1/issues",
......@@ -1745,6 +1755,7 @@ Example response:
"merge_method": "merge",
"autoclose_referenced_issues": true,
"suggestion_commit_message": null,
"container_registry_image_prefix": "registry.example.com/diaspora/diaspora-project-site",
"_links": {
"self": "http://example.com/api/v4/projects",
"issues": "http://example.com/api/v4/projects/1/issues",
......@@ -1858,6 +1869,7 @@ Example response:
"merge_method": "merge",
"autoclose_referenced_issues": true,
"suggestion_commit_message": null,
"container_registry_image_prefix": "registry.example.com/diaspora/diaspora-project-site",
"_links": {
"self": "http://example.com/api/v4/projects",
"issues": "http://example.com/api/v4/projects/1/issues",
......@@ -2354,6 +2366,7 @@ Example response:
"avatar_url": null,
"web_url": "https://gitlab.example.com/groups/cute-cats"
},
"container_registry_image_prefix": "registry.example.com/cute-cats/hello-world",
"_links": {
"self": "https://gitlab.example.com/api/v4/projects/7",
"issues": "https://gitlab.example.com/api/v4/projects/7/issues",
......
......@@ -5,6 +5,8 @@ module API
class Project < BasicProjectDetails
include ::API::Helpers::RelatedResourcesHelpers
expose :container_registry_url, as: :container_registry_image_prefix, if: -> (_, _) { Gitlab.config.registry.enabled }
expose :_links do
expose :self do |project|
expose_url(api_v4_projects_path(id: project.id))
......
......@@ -56,6 +56,7 @@ itself: # project
- can_create_merge_request_in
- compliance_frameworks
- container_expiration_policy
- container_registry_image_prefix
- default_branch
- empty_repo
- forks_count
......
......@@ -1540,6 +1540,10 @@ RSpec.describe API::Projects do
end
context 'when authenticated as an admin' do
before do
stub_container_registry_config(enabled: true, host_port: 'registry.example.org:5000')
end
let(:project_attributes_file) { 'spec/requests/api/project_attributes.yml' }
let(:project_attributes) { YAML.load_file(project_attributes_file) }
......@@ -1569,7 +1573,7 @@ RSpec.describe API::Projects do
keys
end
it 'returns a project by id' do
it 'returns a project by id', :aggregate_failures do
project
project_member
group = create(:group)
......@@ -1587,6 +1591,7 @@ RSpec.describe API::Projects do
expect(json_response['ssh_url_to_repo']).to be_present
expect(json_response['http_url_to_repo']).to be_present
expect(json_response['web_url']).to be_present
expect(json_response['container_registry_image_prefix']).to eq("registry.example.org:5000/#{project.full_path}")
expect(json_response['owner']).to be_a Hash
expect(json_response['name']).to eq(project.name)
expect(json_response['path']).to be_present
......@@ -1644,9 +1649,10 @@ RSpec.describe API::Projects do
before do
project
project_member
stub_container_registry_config(enabled: true, host_port: 'registry.example.org:5000')
end
it 'returns a project by id' do
it 'returns a project by id', :aggregate_failures do
group = create(:group)
link = create(:project_group_link, project: project, group: group)
......@@ -1662,6 +1668,7 @@ RSpec.describe API::Projects do
expect(json_response['ssh_url_to_repo']).to be_present
expect(json_response['http_url_to_repo']).to be_present
expect(json_response['web_url']).to be_present
expect(json_response['container_registry_image_prefix']).to eq("registry.example.org:5000/#{project.full_path}")
expect(json_response['owner']).to be_a Hash
expect(json_response['name']).to eq(project.name)
expect(json_response['path']).to be_present
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment