BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
0b946029
Commit
0b946029
authored
Jan 13, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update build artifacts API
We do not want to allow runners to upload a metadata file. This needs to be generated by Workhorse only.
parent
6d7a7707
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
23 deletions
+43
-23
builds.rb
lib/ci/api/builds.rb
+8
-9
entities.rb
lib/ci/api/entities.rb
+0
-1
builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+35
-13
No files found.
lib/ci/api/builds.rb
View file @
0b946029
...
@@ -79,14 +79,13 @@ module Ci
...
@@ -79,14 +79,13 @@ module Ci
# id (required) - The ID of a build
# id (required) - The ID of a build
# token (required) - The build authorization token
# token (required) - The build authorization token
# file (required) - Artifacts file
# file (required) - Artifacts file
# metadata (optional) - Artifacts metadata file
# Parameters (accelerated by GitLab Workhorse):
# Parameters (accelerated by GitLab Workhorse):
# file.path - path to locally stored body (generated by Workhorse)
# file.path - path to locally stored body (generated by Workhorse)
# file.name - real filename as send in Content-Disposition
# file.name - real filename as send in Content-Disposition
# file.type - real content type as send in Content-Type
# file.type - real content type as send in Content-Type
# metadata.path - path to locally stored body (generated by Workhorse)
# metadata.path - path to locally stored body (generated by Workhorse)
# metadata.name -
real filename as send in Content-Disposition
# metadata.name -
filename (generated by Workhorse)
# metadata.type -
real content type as send in Content-Type
# metadata.type -
content type (returned by Workhorse)
# Headers:
# Headers:
# BUILD-TOKEN (required) - The build authorization token, the same as token
# BUILD-TOKEN (required) - The build authorization token, the same as token
# Body:
# Body:
...
@@ -101,19 +100,19 @@ module Ci
...
@@ -101,19 +100,19 @@ module Ci
not_found!
unless
build
not_found!
unless
build
authenticate_build_token!
(
build
)
authenticate_build_token!
(
build
)
forbidden!
(
'build is not running'
)
unless
build
.
running?
forbidden!
(
'build is not running'
)
unless
build
.
running?
forbidden!
(
'metadata reserved for workhorse'
)
if
params
[
:metadata
]
artifacts_upload_path
=
ArtifactUploader
.
artifacts_upload_path
artifacts_upload_path
=
ArtifactUploader
.
artifacts_upload_path
artifacts
=
uploaded_file!
(
:file
,
artifacts_upload_path
)
artifacts
=
uploaded_file!
(
:file
,
artifacts_upload_path
)
file_to_large!
unless
artifacts
.
size
<
max_artifacts_size
file_to_large!
unless
artifacts
.
size
<
max_artifacts_size
artifacts_attributes
=
{
artifacts_file:
artifacts
}
build
.
artifacts_file
=
artifacts
if
params
[
:metadata
]
||
params
[
'metadata.path'
.
to_sym
]
if
params
[
:'metadata.path'
]
&&
params
[
:'metadata.name'
]
metadata
=
uploaded_file!
(
:metadata
,
artifacts_upload_path
)
build
.
artifacts_metadata
=
uploaded_file!
(
:metadata
,
artifacts_upload_path
)
artifacts_attributes
.
store
(
:artifacts_metadata
,
metadata
)
end
end
if
build
.
update_attributes
(
artifacts_attributes
)
if
build
.
save
present
build
,
with:
Entities
::
Build
present
(
build
,
with:
Entities
::
Build
)
else
else
render_validation_error!
(
build
)
render_validation_error!
(
build
)
end
end
...
...
lib/ci/api/entities.rb
View file @
0b946029
...
@@ -31,7 +31,6 @@ module Ci
...
@@ -31,7 +31,6 @@ module Ci
expose
:variables
expose
:variables
expose
:artifacts_file
,
using:
ArtifactFile
expose
:artifacts_file
,
using:
ArtifactFile
expose
:artifacts_metadata
,
using:
ArtifactFile
end
end
class
Runner
<
Grape
::
Entity
class
Runner
<
Grape
::
Entity
...
...
spec/requests/ci/api/builds_spec.rb
View file @
0b946029
...
@@ -210,27 +210,49 @@ describe Ci::API::API do
...
@@ -210,27 +210,49 @@ describe Ci::API::API do
end
end
end
end
context
"should post artifacts metadata"
do
context
'should post artifacts file and metadata file'
do
let!
(
:artifacts
)
{
file_upload
}
let!
(
:artifacts
)
{
file_upload
}
let!
(
:metadata
)
{
file_upload2
}
let!
(
:metadata
)
{
file_upload2
}
let
(
:stored_artifacts_file
)
{
build
.
reload
.
artifacts_file
.
file
}
let
(
:stored_metadata_file
)
{
build
.
reload
.
artifacts_metadata
.
file
}
before
do
before
do
build
.
run!
build
.
run!
post
(
post_url
,
post_data
,
headers_with_token
)
end
post_data
=
{
context
'post data accelerated by workhorse is correct'
do
'file.path'
=>
artifacts
.
path
,
let
(
:post_data
)
do
'file.name'
=>
artifacts
.
original_filename
,
{
'file.path'
=>
artifacts
.
path
,
'metadata.path'
=>
metadata
.
path
,
'file.name'
=>
artifacts
.
original_filename
,
'metadata.name'
=>
metadata
.
original_filename
'metadata.path'
=>
metadata
.
path
,
}
'metadata.name'
=>
metadata
.
original_filename
}
end
post
post_url
,
post_data
,
headers_with_token
it
'responds with valid status'
do
expect
(
response
.
status
).
to
eq
(
201
)
end
it
'stores artifacts and artifacts metadata'
do
expect
(
stored_artifacts_file
.
original_filename
).
to
eq
(
artifacts
.
original_filename
)
expect
(
stored_metadata_file
.
original_filename
).
to
eq
(
metadata
.
original_filename
)
end
end
end
it
'stores artifacts and artifacts metadata'
do
context
'runner sends metadata file'
do
expect
(
response
.
status
).
to
eq
(
201
)
let
(
:post_data
)
do
expect
(
json_response
[
'artifacts_file'
][
'filename'
]).
to
eq
(
artifacts
.
original_filename
)
{
'file'
=>
artifacts
,
'metadata'
=>
metadata
}
expect
(
json_response
[
'artifacts_metadata'
][
'filename'
]).
to
eq
(
metadata
.
original_filename
)
end
it
'is expected to respond with forbbiden'
do
expect
(
response
.
status
).
to
eq
(
403
)
end
it
'does not store artifacts or metadata'
do
expect
(
stored_artifacts_file
).
to
be_nil
expect
(
stored_metadata_file
).
to
be_nil
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment