Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
385f37a7
Commit
385f37a7
authored
May 28, 2018
by
Kamil Trzciński
Committed by
Dylan Griffith
May 31, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve runner registration API
parent
cfee3e0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
10 deletions
+14
-10
lib/api/runner.rb
lib/api/runner.rb
+9
-7
spec/requests/api/runner_spec.rb
spec/requests/api/runner_spec.rb
+5
-3
No files found.
lib/api/runner.rb
View file @
385f37a7
...
...
@@ -21,24 +21,26 @@ module API
attributes
=
attributes_for_keys
([
:description
,
:active
,
:locked
,
:run_untagged
,
:tag_list
,
:maximum_timeout
])
.
merge
(
get_runner_details_from_request
)
runner
=
attributes
=
if
runner_registration_token_valid?
# Create shared runner. Requires admin access
Ci
::
Runner
.
create
(
attributes
.
merge
(
is_shared:
true
,
runner_type: :instance_type
)
)
attributes
.
merge
(
is_shared:
true
,
runner_type: :instance_type
)
elsif
project
=
Project
.
find_by
(
runners_token:
params
[
:token
])
# Create a specific runner for the project
project
.
runners
.
create
(
attributes
.
merge
(
runner_type: :project_type
)
)
attributes
.
merge
(
is_shared:
false
,
runner_type: :project_type
,
projects:
[
project
]
)
elsif
group
=
Group
.
find_by
(
runners_token:
params
[
:token
])
# Create a specific runner for the group
group
.
runners
.
create
(
attributes
.
merge
(
runner_type: :group_type
))
attributes
.
merge
(
is_shared:
false
,
runner_type: :group_type
,
groups:
[
group
])
else
forbidden!
end
break
forbidden!
unless
runner
runner
=
Ci
::
Runner
.
create
(
attributes
)
if
runner
.
id
if
runner
.
persisted?
present
runner
,
with:
Entities
::
RunnerRegistrationDetails
else
not_found!
render_validation_error!
(
runner
)
end
end
...
...
spec/requests/api/runner_spec.rb
View file @
385f37a7
...
...
@@ -115,7 +115,9 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
post
api
(
'/runners'
),
token:
registration_token
,
run_untagged:
false
expect
(
response
).
to
have_gitlab_http_status
404
expect
(
response
).
to
have_gitlab_http_status
400
expect
(
json_response
[
'message'
]).
to
include
(
'tags_list'
=>
[
'can not be empty when runner is not allowed to pick untagged jobs'
])
end
end
end
...
...
@@ -720,7 +722,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
context
'when runner specifies lower timeout'
do
let
(
:runner
)
{
create
(
:ci_runner
,
maximum_timeout:
1000
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
:project
,
maximum_timeout:
1000
,
projects:
[
project
]
)
}
it
'contains info about timeout overridden by runner'
do
request_job
...
...
@@ -731,7 +733,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
context
'when runner specifies bigger timeout'
do
let
(
:runner
)
{
create
(
:ci_runner
,
maximum_timeout:
2000
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
:project
,
maximum_timeout:
2000
,
projects:
[
project
]
)
}
it
'contains info about timeout not overridden by runner'
do
request_job
...
...
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