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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
5652ff95
Commit
5652ff95
authored
Apr 30, 2018
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Runner#group? -> #assigned_to_group? and Runner#project? -> #assigned_to_project?
parent
8604dbe9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
17 additions
and
17 deletions
+17
-17
app/models/ci/runner.rb
app/models/ci/runner.rb
+3
-3
app/services/ci/register_job_service.rb
app/services/ci/register_job_service.rb
+1
-1
app/views/admin/runners/_runner.html.haml
app/views/admin/runners/_runner.html.haml
+2
-2
app/views/admin/runners/show.html.haml
app/views/admin/runners/show.html.haml
+1
-1
app/views/projects/runners/_runner.html.haml
app/views/projects/runners/_runner.html.haml
+1
-1
lib/api/runners.rb
lib/api/runners.rb
+1
-1
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+8
-8
No files found.
app/models/ci/runner.rb
View file @
5652ff95
...
...
@@ -137,11 +137,11 @@ module Ci
!
shared?
end
def
group?
def
assigned_to_
group?
runner_groups
.
any?
end
def
project?
def
assigned_to_
project?
runner_projects
.
any?
end
...
...
@@ -244,7 +244,7 @@ module Ci
errors
.
add
(
:runner
,
'can only be assigned to one group'
)
end
if
group?
&&
project?
if
assigned_to_group?
&&
assigned_to_
project?
errors
.
add
(
:runner
,
'can only be assigned either to projects or to a group'
)
end
end
...
...
app/services/ci/register_job_service.rb
View file @
5652ff95
...
...
@@ -17,7 +17,7 @@ module Ci
builds
=
if
runner
.
shared?
builds_for_shared_runner
elsif
runner
.
group?
elsif
runner
.
assigned_to_
group?
builds_for_group_runner
else
builds_for_project_runner
...
...
app/views/admin/runners/_runner.html.haml
View file @
5652ff95
...
...
@@ -2,7 +2,7 @@
%td
-
if
runner
.
shared?
%span
.label.label-success
shared
-
elsif
runner
.
group?
-
elsif
runner
.
assigned_to_
group?
%span
.label.label-success
group
-
else
%span
.label.label-info
specific
...
...
@@ -21,7 +21,7 @@
%td
=
runner
.
ip_address
%td
-
if
runner
.
shared?
||
runner
.
group?
-
if
runner
.
shared?
||
runner
.
assigned_to_
group?
n/a
-
else
=
runner
.
projects
.
count
(
:all
)
...
...
app/views/admin/runners/show.html.haml
View file @
5652ff95
...
...
@@ -19,7 +19,7 @@
%p
If you want Runners to build only specific projects, enable them in the table below.
Keep in mind that this is a one way transition.
-
elsif
@runner
.
group?
-
elsif
@runner
.
assigned_to_
group?
.bs-callout.bs-callout-success
%h4
This runner will process jobs from all projects in its group and subgroups
-
else
...
...
app/views/projects/runners/_runner.html.haml
View file @
5652ff95
...
...
@@ -26,7 +26,7 @@
-
else
-
runner_project
=
@project
.
runner_projects
.
find_by
(
runner_id:
runner
)
=
link_to
'Disable for this project'
,
project_runner_project_path
(
@project
,
runner_project
),
data:
{
confirm:
"Are you sure?"
},
method: :delete
,
class:
'btn btn-danger btn-sm'
-
elsif
runner
.
project?
-
elsif
runner
.
assigned_to_
project?
=
form_for
[
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
@project
.
runner_projects
.
new
]
do
|
f
|
=
f
.
hidden_field
:runner_id
,
value:
runner
.
id
=
f
.
submit
'Enable for this project'
,
class:
'btn btn-sm'
...
...
lib/api/runners.rb
View file @
5652ff95
...
...
@@ -205,7 +205,7 @@ module API
def
authenticate_enable_runner!
(
runner
)
forbidden!
(
"Runner is shared"
)
if
runner
.
is_shared?
forbidden!
(
"Runner is locked"
)
if
runner
.
locked?
forbidden!
(
"Runner is a group runner"
)
if
runner
.
group?
forbidden!
(
"Runner is a group runner"
)
if
runner
.
assigned_to_
group?
return
if
current_user
.
admin?
forbidden!
(
"No access granted"
)
unless
user_can_access_runner?
(
runner
)
...
...
spec/models/ci/runner_spec.rb
View file @
5652ff95
...
...
@@ -748,47 +748,47 @@ describe Ci::Runner do
end
end
describe
'group?'
do
describe
'
assigned_to_
group?'
do
it
'returns false when the runner is a project runner'
do
project
=
create
:project
runner
=
create
:ci_runner
,
description:
'Project runner'
,
projects:
[
project
]
expect
(
runner
.
group?
).
to
be
false
expect
(
runner
.
assigned_to_
group?
).
to
be
false
end
it
'returns false when the runner is a shared runner'
do
runner
=
create
:ci_runner
,
:shared
,
description:
'Shared runner'
expect
(
runner
.
group?
).
to
be
false
expect
(
runner
.
assigned_to_
group?
).
to
be
false
end
it
'returns true when the runner is assigned to a group'
do
group
=
create
:group
runner
=
create
:ci_runner
,
description:
'Group runner'
,
groups:
[
group
]
expect
(
runner
.
group?
).
to
be
true
expect
(
runner
.
assigned_to_
group?
).
to
be
true
end
end
describe
'project?'
do
describe
'
assigned_to_
project?'
do
it
'returns false when the runner is a group prunner'
do
group
=
create
:group
runner
=
create
:ci_runner
,
description:
'Group runner'
,
groups:
[
group
]
expect
(
runner
.
project?
).
to
be
false
expect
(
runner
.
assigned_to_
project?
).
to
be
false
end
it
'returns false when the runner is a shared runner'
do
runner
=
create
:ci_runner
,
:shared
,
description:
'Shared runner'
expect
(
runner
.
project?
).
to
be
false
expect
(
runner
.
assigned_to_
project?
).
to
be
false
end
it
'returns true when the runner is assigned to a project'
do
project
=
create
:project
runner
=
create
:ci_runner
,
description:
'Group runner'
,
projects:
[
project
]
expect
(
runner
.
project?
).
to
be
true
expect
(
runner
.
assigned_to_
project?
).
to
be
true
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