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
771cfb14
Commit
771cfb14
authored
Dec 07, 2017
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add clair to merge request model and serializer
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
dd9848c8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
7 deletions
+45
-7
ee/app/models/ee/ci/build.rb
ee/app/models/ee/ci/build.rb
+7
-3
ee/app/models/ee/merge_request.rb
ee/app/models/ee/merge_request.rb
+5
-0
ee/app/models/license.rb
ee/app/models/license.rb
+1
-0
ee/app/serializers/ee/merge_request_entity.rb
ee/app/serializers/ee/merge_request_entity.rb
+21
-3
spec/ee/spec/serializers/merge_request_entity_spec.rb
spec/ee/spec/serializers/merge_request_entity_spec.rb
+11
-1
No files found.
ee/app/models/ee/ci/build.rb
View file @
771cfb14
...
...
@@ -7,6 +7,10 @@ module EE
module
Build
extend
ActiveSupport
::
Concern
CODEQUALITY_FILE
=
'codeclimate.json'
SAST_FILE
=
'gl-sast-report.json'
CLAIR_FILE
=
'gl-clair-report.json'
included
do
scope
:codequality
,
->
()
{
where
(
name:
%w[codequality codeclimate]
)
}
scope
:sast
,
->
()
{
where
(
name:
'sast'
)
}
...
...
@@ -27,15 +31,15 @@ module EE
end
def
has_codeclimate_json?
has_artifact?
(
'codeclimate.json'
)
has_artifact?
(
CODEQUALITY_FILE
)
end
def
has_sast_json?
has_artifact?
(
'gl-sast-report.json'
)
has_artifact?
(
SAST_FILE
)
end
def
has_clair_json?
has_artifact?
(
'gl-clair-report.json'
)
has_artifact?
(
CLAIR_FILE
)
end
private
...
...
ee/app/models/ee/merge_request.rb
View file @
771cfb14
...
...
@@ -12,6 +12,7 @@ module EE
delegate
:codeclimate_artifact
,
to: :head_pipeline
,
prefix: :head
,
allow_nil:
true
delegate
:codeclimate_artifact
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
delegate
:sast_artifact
,
to: :head_pipeline
,
allow_nil:
true
delegate
:clair_artifact
,
to: :head_pipeline
,
allow_nil:
true
delegate
:sha
,
to: :head_pipeline
,
prefix: :head_pipeline
,
allow_nil:
true
delegate
:sha
,
to: :base_pipeline
,
prefix: :base_pipeline
,
allow_nil:
true
end
...
...
@@ -47,5 +48,9 @@ module EE
def
has_sast_data?
sast_artifact
&
.
success?
end
def
has_clair_data?
clair_artifact
&
.
success?
end
end
end
ee/app/models/license.rb
View file @
771cfb14
...
...
@@ -55,6 +55,7 @@ class License < ActiveRecord::Base
EEU_FEATURES
=
EEP_FEATURES
+
%i[
sast
epics
clair
]
.
freeze
# List all features available for early adopters,
...
...
ee/app/serializers/ee/merge_request_entity.rb
View file @
771cfb14
...
...
@@ -7,7 +7,7 @@ module EE
expose
:head_path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:read_build
,
mr
.
head_codeclimate_artifact
)
}
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
source_project
,
merge_request
.
head_codeclimate_artifact
,
path:
'codeclimate.json'
)
path:
Ci
::
Build
::
CODEQUALITY_FILE
)
end
expose
:head_blob_path
,
if:
->
(
mr
,
_
)
{
mr
.
head_pipeline_sha
}
do
|
merge_request
|
...
...
@@ -17,7 +17,7 @@ module EE
expose
:base_path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:read_build
,
mr
.
base_codeclimate_artifact
)
}
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
target_project
,
merge_request
.
base_codeclimate_artifact
,
path:
'codeclimate.json'
)
path:
Ci
::
Build
::
CODEQUALITY_FILE
)
end
expose
:base_blob_path
,
if:
->
(
mr
,
_
)
{
mr
.
base_pipeline_sha
}
do
|
merge_request
|
...
...
@@ -29,7 +29,19 @@ module EE
expose
:path
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
source_project
,
merge_request
.
sast_artifact
,
path:
'gl-sast-report.json'
)
path:
Ci
::
Build
::
SAST_FILE
)
end
expose
:blob_path
,
if:
->
(
mr
,
_
)
{
mr
.
head_pipeline_sha
}
do
|
merge_request
|
project_blob_path
(
merge_request
.
project
,
merge_request
.
head_pipeline_sha
)
end
end
expose
:clair
,
if:
->
(
mr
,
_
)
{
expose_clair_data?
(
mr
,
current_user
)
}
do
expose
:path
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
source_project
,
merge_request
.
clair_artifact
,
path:
Ci
::
Build
::
CLAIR_FILE
)
end
expose
:blob_path
,
if:
->
(
mr
,
_
)
{
mr
.
head_pipeline_sha
}
do
|
merge_request
|
...
...
@@ -45,5 +57,11 @@ module EE
mr
.
has_sast_data?
&&
can?
(
current_user
,
:read_build
,
mr
.
sast_artifact
)
end
def
expose_clair_data?
(
mr
,
current_user
)
mr
.
project
.
feature_available?
(
:clair
)
&&
mr
.
has_clair_data?
&&
can?
(
current_user
,
:read_build
,
mr
.
clair_artifact
)
end
end
end
spec/ee/spec/serializers/merge_request_entity_spec.rb
View file @
771cfb14
...
...
@@ -4,7 +4,6 @@ describe MergeRequestEntity do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
:project
,
:repository
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:build
)
{
create
(
:ci_build
,
name:
'sast'
)
}
let
(
:request
)
{
double
(
'request'
,
current_user:
user
)
}
subject
do
...
...
@@ -12,9 +11,20 @@ describe MergeRequestEntity do
end
it
'has sast data'
do
build
=
create
(
:ci_build
,
name:
'sast'
)
allow
(
subject
).
to
receive
(
:expose_sast_data?
).
and_return
(
true
)
allow
(
merge_request
).
to
receive
(
:sast_artifact
).
and_return
(
build
)
expect
(
subject
.
as_json
).
to
include
(
:sast
)
end
it
'has clair data'
do
build
=
create
(
:ci_build
,
name:
'clair'
)
allow
(
subject
).
to
receive
(
:expose_clair_data?
).
and_return
(
true
)
allow
(
merge_request
).
to
receive
(
:clair_artifact
).
and_return
(
build
)
expect
(
subject
.
as_json
).
to
include
(
:clair
)
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