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
c3f9d80a
Commit
c3f9d80a
authored
May 10, 2018
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename User#ci_authorized_runners -> ci_owned_runners
parent
18821b15
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
18 deletions
+18
-18
app/controllers/projects/settings/ci_cd_controller.rb
app/controllers/projects/settings/ci_cd_controller.rb
+1
-1
app/models/user.rb
app/models/user.rb
+2
-2
app/policies/ci/runner_policy.rb
app/policies/ci/runner_policy.rb
+6
-6
lib/api/runners.rb
lib/api/runners.rb
+1
-1
lib/api/v3/runners.rb
lib/api/v3/runners.rb
+1
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+7
-7
No files found.
app/controllers/projects/settings/ci_cd_controller.rb
View file @
c3f9d80a
...
@@ -69,7 +69,7 @@ module Projects
...
@@ -69,7 +69,7 @@ module Projects
@project_runners
=
@project
.
runners
.
ordered
@project_runners
=
@project
.
runners
.
ordered
@assignable_runners
=
current_user
@assignable_runners
=
current_user
.
ci_
authoriz
ed_runners
.
ci_
own
ed_runners
.
assignable_for
(
project
)
.
assignable_for
(
project
)
.
ordered
.
ordered
.
page
(
params
[
:page
]).
per
(
20
)
.
page
(
params
[
:page
]).
per
(
20
)
...
...
app/models/user.rb
View file @
c3f9d80a
...
@@ -999,8 +999,8 @@ class User < ActiveRecord::Base
...
@@ -999,8 +999,8 @@ class User < ActiveRecord::Base
!
solo_owned_groups
.
present?
!
solo_owned_groups
.
present?
end
end
def
ci_
authoriz
ed_runners
def
ci_
own
ed_runners
@ci_
authoriz
ed_runners
||=
begin
@ci_
own
ed_runners
||=
begin
project_runner_ids
=
Ci
::
RunnerProject
project_runner_ids
=
Ci
::
RunnerProject
.
where
(
project:
authorized_projects
(
Gitlab
::
Access
::
MASTER
))
.
where
(
project:
authorized_projects
(
Gitlab
::
Access
::
MASTER
))
.
select
(
:runner_id
)
.
select
(
:runner_id
)
...
...
app/policies/ci/runner_policy.rb
View file @
c3f9d80a
...
@@ -3,14 +3,14 @@ module Ci
...
@@ -3,14 +3,14 @@ module Ci
with_options
scope: :subject
,
score:
0
with_options
scope: :subject
,
score:
0
condition
(
:locked
,
scope: :subject
)
{
@subject
.
locked?
}
condition
(
:locked
,
scope: :subject
)
{
@subject
.
locked?
}
condition
(
:
authorized_runner
)
{
@user
.
ci_authoriz
ed_runners
.
exists?
(
@subject
.
id
)
}
condition
(
:
owned_runner
)
{
@user
.
ci_own
ed_runners
.
exists?
(
@subject
.
id
)
}
rule
{
anonymous
}.
prevent_all
rule
{
anonymous
}.
prevent_all
rule
{
admin
|
authoriz
ed_runner
}.
enable
:assign_runner
rule
{
admin
|
own
ed_runner
}.
enable
:assign_runner
rule
{
admin
|
authoriz
ed_runner
}.
enable
:read_runner
rule
{
admin
|
own
ed_runner
}.
enable
:read_runner
rule
{
admin
|
authoriz
ed_runner
}.
enable
:update_runner
rule
{
admin
|
own
ed_runner
}.
enable
:update_runner
rule
{
admin
|
authoriz
ed_runner
}.
enable
:delete_runner
rule
{
admin
|
own
ed_runner
}.
enable
:delete_runner
rule
{
admin
|
authorized_runner
}.
enable
:list_runner_jobs
rule
{
admin
|
owned_runner
}.
enable
:list_runner_jobs
rule
{
~
admin
&
locked
}.
prevent
:assign_runner
rule
{
~
admin
&
locked
}.
prevent
:assign_runner
end
end
end
end
lib/api/runners.rb
View file @
c3f9d80a
...
@@ -14,7 +14,7 @@ module API
...
@@ -14,7 +14,7 @@ module API
use
:pagination
use
:pagination
end
end
get
do
get
do
runners
=
filter_runners
(
current_user
.
ci_
authoriz
ed_runners
,
params
[
:scope
],
without:
%w(specific shared)
)
runners
=
filter_runners
(
current_user
.
ci_
own
ed_runners
,
params
[
:scope
],
without:
%w(specific shared)
)
present
paginate
(
runners
),
with:
Entities
::
Runner
present
paginate
(
runners
),
with:
Entities
::
Runner
end
end
...
...
lib/api/v3/runners.rb
View file @
c3f9d80a
...
@@ -58,7 +58,7 @@ module API
...
@@ -58,7 +58,7 @@ module API
end
end
def
user_can_access_runner?
(
runner
)
def
user_can_access_runner?
(
runner
)
current_user
.
ci_
authoriz
ed_runners
.
exists?
(
runner
.
id
)
current_user
.
ci_
own
ed_runners
.
exists?
(
runner
.
id
)
end
end
end
end
end
end
...
...
spec/models/user_spec.rb
View file @
c3f9d80a
...
@@ -1786,7 +1786,7 @@ describe User do
...
@@ -1786,7 +1786,7 @@ describe User do
end
end
end
end
describe
'#ci_
authoriz
ed_runners'
do
describe
'#ci_
own
ed_runners'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:runner_1
)
{
create
(
:ci_runner
)
}
let
(
:runner_1
)
{
create
(
:ci_runner
)
}
let
(
:runner_2
)
{
create
(
:ci_runner
)
}
let
(
:runner_2
)
{
create
(
:ci_runner
)
}
...
@@ -1796,7 +1796,7 @@ describe User do
...
@@ -1796,7 +1796,7 @@ describe User do
let!
(
:group
)
{
create
(
:group
)
}
let!
(
:group
)
{
create
(
:group
)
}
it
'does not load'
do
it
'does not load'
do
expect
(
user
.
ci_
authoriz
ed_runners
).
to
be_empty
expect
(
user
.
ci_
own
ed_runners
).
to
be_empty
end
end
end
end
...
@@ -1805,7 +1805,7 @@ describe User do
...
@@ -1805,7 +1805,7 @@ describe User do
let!
(
:project
)
{
create
(
:project
,
namespace:
namespace
,
runners:
[
runner_1
])
}
let!
(
:project
)
{
create
(
:project
,
namespace:
namespace
,
runners:
[
runner_1
])
}
it
'loads'
do
it
'loads'
do
expect
(
user
.
ci_
authoriz
ed_runners
).
to
contain_exactly
(
runner_1
)
expect
(
user
.
ci_
own
ed_runners
).
to
contain_exactly
(
runner_1
)
end
end
end
end
...
@@ -1818,7 +1818,7 @@ describe User do
...
@@ -1818,7 +1818,7 @@ describe User do
end
end
it
'loads'
do
it
'loads'
do
expect
(
user
.
ci_
authoriz
ed_runners
).
to
contain_exactly
(
runner_2
)
expect
(
user
.
ci_
own
ed_runners
).
to
contain_exactly
(
runner_2
)
end
end
end
end
...
@@ -1833,7 +1833,7 @@ describe User do
...
@@ -1833,7 +1833,7 @@ describe User do
end
end
it
'loads'
do
it
'loads'
do
expect
(
user
.
ci_
authoriz
ed_runners
).
to
contain_exactly
(
runner_1
,
runner_2
)
expect
(
user
.
ci_
own
ed_runners
).
to
contain_exactly
(
runner_1
,
runner_2
)
end
end
end
end
...
@@ -1844,7 +1844,7 @@ describe User do
...
@@ -1844,7 +1844,7 @@ describe User do
end
end
it
'loads'
do
it
'loads'
do
expect
(
user
.
ci_
authoriz
ed_runners
).
to
contain_exactly
(
runner_1
)
expect
(
user
.
ci_
own
ed_runners
).
to
contain_exactly
(
runner_1
)
end
end
end
end
...
@@ -1854,7 +1854,7 @@ describe User do
...
@@ -1854,7 +1854,7 @@ describe User do
end
end
it
'does not load'
do
it
'does not load'
do
expect
(
user
.
ci_
authoriz
ed_runners
).
to
be_empty
expect
(
user
.
ci_
own
ed_runners
).
to
be_empty
end
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