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
Jérome Perrin
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
Hide 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
...
@@ -34,7 +34,7 @@ module Ci
scope
:with_expired_artifacts
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at < ?'
,
Time
.
now
)
}
scope
:with_expired_artifacts
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at < ?'
,
Time
.
now
)
}
scope
:last_month
,
->
()
{
where
(
'created_at > ?'
,
Date
.
today
-
1
.
month
)
}
scope
:last_month
,
->
()
{
where
(
'created_at > ?'
,
Date
.
today
-
1
.
month
)
}
scope
:manual_actions
,
->
()
{
where
(
when: :manual
,
status:
COMPLETED_STATUSES
+
[
:manual
])
}
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_file
,
ArtifactUploader
mount_uploader
:artifacts_metadata
,
ArtifactUploader
mount_uploader
:artifacts_metadata
,
ArtifactUploader
...
...
app/models/ci/runner.rb
View file @
1024718e
...
@@ -41,8 +41,8 @@ module Ci
...
@@ -41,8 +41,8 @@ module Ci
after_destroy
:cleanup_runner_queue
after_destroy
:cleanup_runner_queue
enum
access_level:
{
enum
access_level:
{
un
protected:
0
,
not_
protected:
0
,
protected_
:
1
ref_protected
:
1
}
}
# Searches for runners matching the given query.
# Searches for runners matching the given query.
...
@@ -111,7 +111,7 @@ module Ci
...
@@ -111,7 +111,7 @@ module Ci
end
end
def
can_pick?
(
build
)
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
)
assignable_for?
(
build
.
project
)
&&
accepting_tags?
(
build
)
end
end
...
...
app/services/ci/register_job_service.rb
View file @
1024718e
...
@@ -78,7 +78,7 @@ module Ci
...
@@ -78,7 +78,7 @@ module Ci
def
new_builds
def
new_builds
builds
=
Ci
::
Build
.
pending
.
unstarted
builds
=
Ci
::
Build
.
pending
.
unstarted
builds
=
builds
.
protected_
if
runner
.
protected_
?
builds
=
builds
.
ref_protected
if
runner
.
ref_protected
?
builds
builds
end
end
...
...
app/views/projects/runners/_form.html.haml
View file @
1024718e
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
=
label
:protected
,
"Protected"
,
class:
'control-label'
=
label
:protected
,
"Protected"
,
class:
'control-label'
.col-sm-10
.col-sm-10
.checkbox
.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
%span
.light
This runner will only run on pipelines trigged on protected branches
.form-group
.form-group
=
label
:run_untagged
,
'Run untagged jobs'
,
class:
'control-label'
=
label
:run_untagged
,
'Run untagged jobs'
,
class:
'control-label'
...
...
app/views/projects/runners/show.html.haml
View file @
1024718e
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
%td
=
@runner
.
active?
?
'Yes'
:
'No'
%td
=
@runner
.
active?
?
'Yes'
:
'No'
%tr
%tr
%td
Protected
%td
Protected
%td
=
@runner
.
protected_
?
?
'Yes'
:
'No'
%td
=
@runner
.
ref_protected
?
?
'Yes'
:
'No'
%tr
%tr
%td
Can run untagged jobs
%td
Can run untagged jobs
%td
=
@runner
.
run_untagged?
?
'Yes'
:
'No'
%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
...
@@ -7,7 +7,7 @@ class AddAccessLevelToCiRunners < ActiveRecord::Migration
def
up
def
up
add_column_with_default
(
:ci_runners
,
:access_level
,
:integer
,
add_column_with_default
(
:ci_runners
,
:access_level
,
:integer
,
default:
Ci
::
Runner
.
access_levels
[
'
un
protected'
])
default:
Ci
::
Runner
.
access_levels
[
'
not_
protected'
])
end
end
def
down
def
down
...
...
doc/api/runners.md
View file @
1024718e
...
@@ -159,7 +159,7 @@ PUT /runners/:id
...
@@ -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 |
|
`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 |
|
`run_untagged`
| boolean | no | Flag indicating the runner can execute untagged jobs |
|
`locked`
| boolean | no | Flag indicating the runner is locked |
|
`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"
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
...
@@ -22,12 +22,12 @@ FactoryGirl.define do
active
false
active
false
end
end
trait
:protected
do
trait
:
ref_
protected
do
access_level
'
protected_
'
access_level
'
ref_protected
'
end
end
trait
:
un
protected
do
trait
:
not_
protected
do
access_level
'
un
protected'
access_level
'
not_
protected'
end
end
end
end
end
end
spec/models/ci/build_spec.rb
View file @
1024718e
...
@@ -43,11 +43,11 @@ describe Ci::Build do
...
@@ -43,11 +43,11 @@ describe Ci::Build do
it
{
is_expected
.
not_to
include
(
manual_but_created
)
}
it
{
is_expected
.
not_to
include
(
manual_but_created
)
}
end
end
describe
'.
protected_
'
do
describe
'.
ref_protected
'
do
let!
(
:protected_job
)
{
create
(
:ci_build
,
:protected
)
}
let!
(
:protected_job
)
{
create
(
:ci_build
,
:protected
)
}
let!
(
:unprotected_job
)
{
create
(
:ci_build
,
:unprotected
)
}
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
.
to
include
(
protected_job
)
}
it
{
is_expected
.
not_to
include
(
unprotected_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
...
@@ -227,7 +227,7 @@ describe Ci::Runner do
context
'when runner is protected'
do
context
'when runner is protected'
do
before
do
before
do
runner
.
protected_
!
runner
.
ref_protected
!
end
end
context
'when build is protected'
do
context
'when build is protected'
do
...
@@ -489,18 +489,18 @@ describe Ci::Runner do
...
@@ -489,18 +489,18 @@ describe Ci::Runner do
it
'a protected runner exists'
do
it
'a protected runner exists'
do
expect
(
described_class
.
count
).
to
eq
(
1
)
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
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
before
do
create
(
:ci_runner
,
:
un
protected
)
create
(
:ci_runner
,
:
not_
protected
)
end
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
.
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
end
end
end
...
...
spec/requests/api/runners_spec.rb
View file @
1024718e
...
@@ -192,7 +192,7 @@ describe API::Runners do
...
@@ -192,7 +192,7 @@ describe API::Runners do
tag_list:
[
'ruby2.1'
,
'pgsql'
,
'mysql'
],
tag_list:
[
'ruby2.1'
,
'pgsql'
,
'mysql'
],
run_untagged:
'false'
,
run_untagged:
'false'
,
locked:
'true'
,
locked:
'true'
,
access_level:
Ci
::
Runner
.
access_levels
[
'
protected_
'
])
access_level:
Ci
::
Runner
.
access_levels
[
'
ref_protected
'
])
shared_runner
.
reload
shared_runner
.
reload
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
...
@@ -201,7 +201,7 @@ describe API::Runners do
...
@@ -201,7 +201,7 @@ describe API::Runners do
expect
(
shared_runner
.
tag_list
).
to
include
(
'ruby2.1'
,
'pgsql'
,
'mysql'
)
expect
(
shared_runner
.
tag_list
).
to
include
(
'ruby2.1'
,
'pgsql'
,
'mysql'
)
expect
(
shared_runner
.
run_untagged?
).
to
be
(
false
)
expect
(
shared_runner
.
run_untagged?
).
to
be
(
false
)
expect
(
shared_runner
.
locked?
).
to
be
(
true
)
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
)
expect
(
shared_runner
.
ensure_runner_queue_value
)
.
not_to
eq
(
runner_queue_value
)
.
not_to
eq
(
runner_queue_value
)
end
end
...
...
spec/services/ci/register_job_service_spec.rb
View file @
1024718e
...
@@ -215,7 +215,7 @@ module Ci
...
@@ -215,7 +215,7 @@ module Ci
end
end
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
context
'when a job is protected'
do
let!
(
:pending_build
)
{
create
(
:ci_build
,
:protected
,
pipeline:
pipeline
)
}
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