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
Léo-Paul Géneau
gitlab-ce
Commits
1024718e
Commit
1024718e
authored
Aug 29, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor access_level to not_protected and ref_protected
parent
38759832
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
24 additions
and
24 deletions
+24
-24
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
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/projects/runners/_form.html.haml
app/views/projects/runners/_form.html.haml
+1
-1
app/views/projects/runners/show.html.haml
app/views/projects/runners/show.html.haml
+1
-1
db/migrate/20170816133938_add_access_level_to_ci_runners.rb
db/migrate/20170816133938_add_access_level_to_ci_runners.rb
+1
-1
doc/api/runners.md
doc/api/runners.md
+1
-1
spec/factories/ci/runners.rb
spec/factories/ci/runners.rb
+4
-4
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+2
-2
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+6
-6
spec/requests/api/runners_spec.rb
spec/requests/api/runners_spec.rb
+2
-2
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+1
-1
No files found.
app/models/ci/build.rb
View file @
1024718e
...
...
@@ -34,7 +34,7 @@ module Ci
scope
:with_expired_artifacts
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at < ?'
,
Time
.
now
)
}
scope
:last_month
,
->
()
{
where
(
'created_at > ?'
,
Date
.
today
-
1
.
month
)
}
scope
:manual_actions
,
->
()
{
where
(
when: :manual
,
status:
COMPLETED_STATUSES
+
[
:manual
])
}
scope
:
protected_
,
->
{
where
(
protected:
true
)
}
scope
:
ref_protected
,
->
{
where
(
protected:
true
)
}
mount_uploader
:artifacts_file
,
ArtifactUploader
mount_uploader
:artifacts_metadata
,
ArtifactUploader
...
...
app/models/ci/runner.rb
View file @
1024718e
...
...
@@ -41,8 +41,8 @@ module Ci
after_destroy
:cleanup_runner_queue
enum
access_level:
{
un
protected:
0
,
protected_
:
1
not_
protected:
0
,
ref_protected
:
1
}
# Searches for runners matching the given query.
...
...
@@ -111,7 +111,7 @@ module Ci
end
def
can_pick?
(
build
)
return
false
if
self
.
protected_
?
&&
!
build
.
protected?
return
false
if
self
.
ref_protected
?
&&
!
build
.
protected?
assignable_for?
(
build
.
project
)
&&
accepting_tags?
(
build
)
end
...
...
app/services/ci/register_job_service.rb
View file @
1024718e
...
...
@@ -78,7 +78,7 @@ module Ci
def
new_builds
builds
=
Ci
::
Build
.
pending
.
unstarted
builds
=
builds
.
protected_
if
runner
.
protected_
?
builds
=
builds
.
ref_protected
if
runner
.
ref_protected
?
builds
end
...
...
app/views/projects/runners/_form.html.haml
View file @
1024718e
...
...
@@ -10,7 +10,7 @@
=
label
:protected
,
"Protected"
,
class:
'control-label'
.col-sm-10
.checkbox
=
f
.
check_box
:access_level
,
{},
'
protected_'
,
'un
protected'
=
f
.
check_box
:access_level
,
{},
'
ref_protected'
,
'not_
protected'
%span
.light
This runner will only run on pipelines trigged on protected branches
.form-group
=
label
:run_untagged
,
'Run untagged jobs'
,
class:
'control-label'
...
...
app/views/projects/runners/show.html.haml
View file @
1024718e
...
...
@@ -21,7 +21,7 @@
%td
=
@runner
.
active?
?
'Yes'
:
'No'
%tr
%td
Protected
%td
=
@runner
.
protected_
?
?
'Yes'
:
'No'
%td
=
@runner
.
ref_protected
?
?
'Yes'
:
'No'
%tr
%td
Can run untagged jobs
%td
=
@runner
.
run_untagged?
?
'Yes'
:
'No'
...
...
db/migrate/20170816133938_add_access_level_to_ci_runners.rb
View file @
1024718e
...
...
@@ -7,7 +7,7 @@ class AddAccessLevelToCiRunners < ActiveRecord::Migration
def
up
add_column_with_default
(
:ci_runners
,
:access_level
,
:integer
,
default:
Ci
::
Runner
.
access_levels
[
'
un
protected'
])
default:
Ci
::
Runner
.
access_levels
[
'
not_
protected'
])
end
def
down
...
...
doc/api/runners.md
View file @
1024718e
...
...
@@ -159,7 +159,7 @@ PUT /runners/:id
|
`tag_list`
| array | no | The list of tags for a runner; put array of tags, that should be finally assigned to a runner |
|
`run_untagged`
| boolean | no | Flag indicating the runner can execute untagged jobs |
|
`locked`
| boolean | no | Flag indicating the runner is locked |
|
`access_level`
| integer | no | The access_level of the runner;
`
unprotected`
: 0,
`
protected`
: 1 |
|
`access_level`
| integer | no | The access_level of the runner;
`
not_protected`
: 0,
`ref_
protected`
: 1 |
```
curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/runners/6" --form "description=test-1-20150125-test" --form "tag_list=ruby,mysql,tag1,tag2"
...
...
spec/factories/ci/runners.rb
View file @
1024718e
...
...
@@ -22,12 +22,12 @@ FactoryGirl.define do
active
false
end
trait
:protected
do
access_level
'
protected_
'
trait
:
ref_
protected
do
access_level
'
ref_protected
'
end
trait
:
un
protected
do
access_level
'
un
protected'
trait
:
not_
protected
do
access_level
'
not_
protected'
end
end
end
spec/models/ci/build_spec.rb
View file @
1024718e
...
...
@@ -43,11 +43,11 @@ describe Ci::Build do
it
{
is_expected
.
not_to
include
(
manual_but_created
)
}
end
describe
'.
protected_
'
do
describe
'.
ref_protected
'
do
let!
(
:protected_job
)
{
create
(
:ci_build
,
:protected
)
}
let!
(
:unprotected_job
)
{
create
(
:ci_build
,
:unprotected
)
}
subject
{
described_class
.
protected_
}
subject
{
described_class
.
ref_protected
}
it
{
is_expected
.
to
include
(
protected_job
)
}
it
{
is_expected
.
not_to
include
(
unprotected_job
)
}
...
...
spec/models/ci/runner_spec.rb
View file @
1024718e
...
...
@@ -227,7 +227,7 @@ describe Ci::Runner do
context
'when runner is protected'
do
before
do
runner
.
protected_
!
runner
.
ref_protected
!
end
context
'when build is protected'
do
...
...
@@ -489,18 +489,18 @@ describe Ci::Runner do
it
'a protected runner exists'
do
expect
(
described_class
.
count
).
to
eq
(
1
)
expect
(
described_class
.
last
.
protected_
?
).
to
eq
(
true
)
expect
(
described_class
.
last
.
ref_protected
?
).
to
eq
(
true
)
end
end
context
'when access_level of a runner is
un
protected'
do
context
'when access_level of a runner is
not_
protected'
do
before
do
create
(
:ci_runner
,
:
un
protected
)
create
(
:ci_runner
,
:
not_
protected
)
end
it
'an
un
protected runner exists'
do
it
'an
not_
protected runner exists'
do
expect
(
described_class
.
count
).
to
eq
(
1
)
expect
(
described_class
.
last
.
un
protected?
).
to
eq
(
true
)
expect
(
described_class
.
last
.
not_
protected?
).
to
eq
(
true
)
end
end
end
...
...
spec/requests/api/runners_spec.rb
View file @
1024718e
...
...
@@ -192,7 +192,7 @@ describe API::Runners do
tag_list:
[
'ruby2.1'
,
'pgsql'
,
'mysql'
],
run_untagged:
'false'
,
locked:
'true'
,
access_level:
Ci
::
Runner
.
access_levels
[
'
protected_
'
])
access_level:
Ci
::
Runner
.
access_levels
[
'
ref_protected
'
])
shared_runner
.
reload
expect
(
response
).
to
have_http_status
(
200
)
...
...
@@ -201,7 +201,7 @@ describe API::Runners do
expect
(
shared_runner
.
tag_list
).
to
include
(
'ruby2.1'
,
'pgsql'
,
'mysql'
)
expect
(
shared_runner
.
run_untagged?
).
to
be
(
false
)
expect
(
shared_runner
.
locked?
).
to
be
(
true
)
expect
(
shared_runner
.
protected_
?
).
to
be_truthy
expect
(
shared_runner
.
ref_protected
?
).
to
be_truthy
expect
(
shared_runner
.
ensure_runner_queue_value
)
.
not_to
eq
(
runner_queue_value
)
end
...
...
spec/services/ci/register_job_service_spec.rb
View file @
1024718e
...
...
@@ -215,7 +215,7 @@ module Ci
end
end
context
'when a runner is
un
protected'
do
context
'when a runner is
not_
protected'
do
context
'when a job is protected'
do
let!
(
:pending_build
)
{
create
(
:ci_build
,
:protected
,
pipeline:
pipeline
)
}
...
...
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