Commit e72fd1ff authored by Nick Kipling's avatar Nick Kipling

Added addtional pipeline info to packages

Added user to pipeline info for packages
Removed build_info prop
Updated schema in tests
Updated docs
parent bd187a56
...@@ -87,15 +87,17 @@ Example response: ...@@ -87,15 +87,17 @@ Example response:
"delete_api_path": "/namespace1/project1/-/packages/1" "delete_api_path": "/namespace1/project1/-/packages/1"
}, },
"created_at": "2019-11-27T03:37:38.711Z", "created_at": "2019-11-27T03:37:38.711Z",
"build_info": { "pipeline": {
"pipeline": { "id": 123,
"id": 123, "status": "pending",
"status": "pending", "ref": "new-pipeline",
"ref": "new-pipeline", "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a", "web_url": "https://example.com/foo/bar/pipelines/47",
"web_url": "https://example.com/foo/bar/pipelines/47", "created_at": "2016-08-11T11:28:34.085Z",
"created_at": "2016-08-11T11:28:34.085Z", "updated_at": "2016-08-11T11:32:35.169Z",
"updated_at": "2016-08-11T11:32:35.169Z", "user": {
"name": "Administrator",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
} }
} }
}, },
...@@ -109,15 +111,17 @@ Example response: ...@@ -109,15 +111,17 @@ Example response:
"delete_api_path": "/namespace1/project1/-/packages/1" "delete_api_path": "/namespace1/project1/-/packages/1"
}, },
"created_at": "2019-11-27T03:37:38.711Z", "created_at": "2019-11-27T03:37:38.711Z",
"build_info": { "pipeline": {
"pipeline": { "id": 123,
"id": 123, "status": "pending",
"status": "pending", "ref": "new-pipeline",
"ref": "new-pipeline", "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a", "web_url": "https://example.com/foo/bar/pipelines/47",
"web_url": "https://example.com/foo/bar/pipelines/47", "created_at": "2016-08-11T11:28:34.085Z",
"created_at": "2016-08-11T11:28:34.085Z", "updated_at": "2016-08-11T11:32:35.169Z",
"updated_at": "2016-08-11T11:32:35.169Z", "user": {
"name": "Administrator",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
} }
} }
} }
...@@ -163,15 +167,17 @@ Example response: ...@@ -163,15 +167,17 @@ Example response:
"delete_api_path": "/namespace1/project1/-/packages/1" "delete_api_path": "/namespace1/project1/-/packages/1"
}, },
"created_at": "2019-11-27T03:37:38.711Z", "created_at": "2019-11-27T03:37:38.711Z",
"build_info": { "pipeline": {
"pipeline": { "id": 123,
"id": 123, "status": "pending",
"status": "pending", "ref": "new-pipeline",
"ref": "new-pipeline", "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a", "web_url": "https://example.com/foo/bar/pipelines/47",
"web_url": "https://example.com/foo/bar/pipelines/47", "created_at": "2016-08-11T11:28:34.085Z",
"created_at": "2016-08-11T11:28:34.085Z", "updated_at": "2016-08-11T11:32:35.169Z",
"updated_at": "2016-08-11T11:32:35.169Z", "user": {
"name": "Administrator",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
} }
} }
} }
......
...@@ -25,9 +25,12 @@ module EE ...@@ -25,9 +25,12 @@ module EE
expose :created_at expose :created_at
expose :project_id, if: ->(_, opts) { opts[:group] } expose :project_id, if: ->(_, opts) { opts[:group] }
expose :project_path, if: ->(obj, opts) { opts[:group] && Ability.allowed?(opts[:user], :read_project, obj.project) } expose :project_path, if: ->(obj, opts) { opts[:group] && Ability.allowed?(opts[:user], :read_project, obj.project) }
expose :build_info, using: Package::BuildInfo
expose :tags expose :tags
expose :pipeline, if: ->(obj) { obj.build_info } do |package|
::API::Entities::Pipeline.represent package.build_info.pipeline, only: [:created_at, :id, :sha, :ref, :status, :updated_at, :web_url, user: [:name, :avatar_url]]
end
private private
def project_path def project_path
......
{ {
"type": "object", "type": "object",
"required": ["name", "version", "package_type"], "required": ["name", "version", "package_type", "pipeline"],
"properties": { "properties": {
"name": { "type": "string" }, "name": { "type": "string" },
"version": { "type": "string" }, "version": { "type": "string" },
"package_type": { "type": "string" }, "package_type": { "type": "string" },
"build_info": { "pipeline": { "$ref": "../pipeline.json" }
"type": "object",
"required": ["pipeline"],
"properties": {
"pipeline": { "$ref": "../pipeline.json" }
}
}
} }
} }
...@@ -227,10 +227,10 @@ describe API::ProjectPackages do ...@@ -227,10 +227,10 @@ describe API::ProjectPackages do
it_behaves_like 'destroy url' it_behaves_like 'destroy url'
end end
context 'with build info' do context 'with pipeline' do
let!(:package1) { create(:npm_package, :with_build, project: project) } let!(:package1) { create(:npm_package, :with_build, project: project) }
it 'returns the build info' do it 'returns the pipeline info' do
project.add_developer(user) project.add_developer(user)
get api(package_url, user) get api(package_url, user)
......
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