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
e2c64602
Commit
e2c64602
authored
Oct 23, 2018
by
Olivier Gonzalez
Committed by
Kamil Trzciński
Oct 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename 'sast_container' to 'container_scanning' in GITLAB_FEATURES
parent
bf68a072
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
16 deletions
+100
-16
ee/app/models/ee/ci/pipeline.rb
ee/app/models/ee/ci/pipeline.rb
+7
-7
ee/app/models/license.rb
ee/app/models/license.rb
+1
-0
ee/spec/models/ci/pipeline_spec.rb
ee/spec/models/ci/pipeline_spec.rb
+91
-8
lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml
lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml
+1
-1
No files found.
ee/app/models/ee/ci/pipeline.rb
View file @
e2c64602
...
@@ -19,12 +19,12 @@ module EE
...
@@ -19,12 +19,12 @@ module EE
# This structure describes feature levels
# This structure describes feature levels
# to access the file types for given reports
# to access the file types for given reports
LEGACY_
REPORT_LICENSED_FEATURES
=
{
REPORT_LICENSED_FEATURES
=
{
codequality:
nil
,
codequality:
nil
,
sast:
:sast
,
sast:
%i[sast]
,
dependency_scanning:
:dependency_scanning
,
dependency_scanning:
%i[dependency_scanning]
,
container_scanning:
:sast_container
,
container_scanning:
%i[container_scanning sast_container]
,
dast:
:dast
dast:
%i[dast]
}.
freeze
}.
freeze
# Deprecated, to be removed in 12.0
# Deprecated, to be removed in 12.0
...
@@ -112,8 +112,8 @@ module EE
...
@@ -112,8 +112,8 @@ module EE
private
private
def
available_licensed_report_type?
(
file_type
)
def
available_licensed_report_type?
(
file_type
)
feature_name
=
LEGACY_
REPORT_LICENSED_FEATURES
.
fetch
(
file_type
)
feature_name
s
=
REPORT_LICENSED_FEATURES
.
fetch
(
file_type
)
feature_name
.
nil?
||
project
.
feature_available?
(
feature_name
)
feature_name
s
.
nil?
||
feature_names
.
any?
{
|
feature
|
project
.
feature_available?
(
feature
)
}
end
end
def
artifacts_with_files
def
artifacts_with_files
...
...
ee/app/models/license.rb
View file @
e2c64602
...
@@ -78,6 +78,7 @@ class License < ActiveRecord::Base
...
@@ -78,6 +78,7 @@ class License < ActiveRecord::Base
license_management
license_management
sast
sast
sast_container
sast_container
container_scanning
cluster_health
cluster_health
dast
dast
epics
epics
...
...
ee/spec/models/ci/pipeline_spec.rb
View file @
e2c64602
...
@@ -153,20 +153,92 @@ describe Ci::Pipeline do
...
@@ -153,20 +153,92 @@ describe Ci::Pipeline do
end
end
end
end
shared_examples
'unlicensed report type'
do
context
'when there is no licensed feature for artifact file type'
do
it
'returns the artifact'
do
expect
(
subject
).
to
eq
(
expected
)
end
end
end
shared_examples
'licensed report type'
do
|
feature
|
context
'when licensed features is NOT available'
do
it
'returns nil'
do
allow
(
pipeline
.
project
).
to
receive
(
:feature_available?
)
.
with
(
feature
).
and_return
(
false
)
expect
(
subject
).
to
be_nil
end
end
context
'when licensed feature is available'
do
it
'returns the artifact'
do
allow
(
pipeline
.
project
).
to
receive
(
:feature_available?
)
.
with
(
feature
).
and_return
(
true
)
expect
(
subject
).
to
eq
(
expected
)
end
end
end
shared_examples
'multi-licensed report type'
do
|
features
|
context
'when NONE of the licensed features are available'
do
it
'returns nil'
do
features
.
each
do
|
feature
|
allow
(
pipeline
.
project
).
to
receive
(
:feature_available?
)
.
with
(
feature
).
and_return
(
false
)
end
expect
(
subject
).
to
be_nil
end
end
context
'when at least one licensed feature is available'
do
features
.
each
do
|
feature
|
it
'returns the artifact'
do
allow
(
pipeline
.
project
).
to
receive
(
:feature_available?
)
.
with
(
feature
).
and_return
(
true
)
features
.
reject
{
|
f
|
f
==
feature
}.
each
do
|
disabled_feature
|
allow
(
pipeline
.
project
).
to
receive
(
:feature_available?
)
.
with
(
disabled_feature
).
and_return
(
true
)
end
expect
(
subject
).
to
eq
(
expected
)
end
end
end
end
describe
'#report_artifact_for_file_type'
do
describe
'#report_artifact_for_file_type'
do
let
(
:file_type
)
{
:codequality
}
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let!
(
:artifact
)
{
create
(
:ci_job_artifact
,
:codequality
,
job:
build
)
}
let!
(
:artifact
)
do
create
(
:ci_job_artifact
,
job:
build
,
file_type:
file_type
,
file_format:
::
Ci
::
JobArtifact
::
TYPE_AND_FORMAT_PAIRS
[
file_type
])
end
subject
{
pipeline
.
report_artifact_for_file_type
(
file_type
)
}
subject
{
pipeline
.
report_artifact_for_file_type
(
file_type
)
}
it
'returns the artifact'
do
described_class
::
REPORT_LICENSED_FEATURES
.
each
do
|
file_type
,
licensed_features
|
expect
(
subject
).
to
eq
(
artifact
)
context
"for file_type:
#{
file_type
}
"
do
let
(
:file_type
)
{
file_type
}
let
(
:expected
)
{
artifact
}
if
licensed_features
.
nil?
it_behaves_like
'unlicensed report type'
elsif
licensed_features
.
size
==
1
it_behaves_like
'licensed report type'
,
licensed_features
.
first
else
it_behaves_like
'multi-licensed report type'
,
licensed_features
end
end
end
end
end
end
describe
'#legacy_report_artifact_for_file_type'
do
describe
'#legacy_report_artifact_for_file_type'
do
let
(
:file_type
)
{
:codequality
}
let
(
:build_name
)
{
::
EE
::
Ci
::
Pipeline
::
LEGACY_REPORT_FORMATS
[
file_type
][
:names
].
first
}
let
(
:build_name
)
{
::
EE
::
Ci
::
Pipeline
::
LEGACY_REPORT_FORMATS
[
file_type
][
:names
].
first
}
let
(
:artifact_path
)
{
::
EE
::
Ci
::
Pipeline
::
LEGACY_REPORT_FORMATS
[
file_type
][
:files
].
first
}
let
(
:artifact_path
)
{
::
EE
::
Ci
::
Pipeline
::
LEGACY_REPORT_FORMATS
[
file_type
][
:files
].
first
}
...
@@ -185,10 +257,21 @@ describe Ci::Pipeline do
...
@@ -185,10 +257,21 @@ describe Ci::Pipeline do
)
)
end
end
subject
{
pipeline
.
legacy_report_artifact_for_file_type
(
:codequality
)
}
subject
{
pipeline
.
legacy_report_artifact_for_file_type
(
file_type
)
}
described_class
::
REPORT_LICENSED_FEATURES
.
each
do
|
file_type
,
licensed_features
|
context
"for file_type:
#{
file_type
}
"
do
let
(
:file_type
)
{
file_type
}
let
(
:expected
)
{
OpenStruct
.
new
(
build:
build
,
path:
artifact_path
)
}
it
'returns the artifact'
do
if
licensed_features
.
nil?
expect
(
subject
).
to
eq
(
OpenStruct
.
new
(
build:
build
,
path:
artifact_path
))
it_behaves_like
'unlicensed report type'
elsif
licensed_features
.
size
==
1
it_behaves_like
'licensed report type'
,
licensed_features
.
first
else
it_behaves_like
'multi-licensed report type'
,
licensed_features
end
end
end
end
end
end
...
...
lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml
View file @
e2c64602
...
@@ -210,7 +210,7 @@ container_scanning:
...
@@ -210,7 +210,7 @@ container_scanning:
refs
:
refs
:
-
branches
-
branches
variables
:
variables
:
-
$GITLAB_FEATURES =~ /\b
sast_container
\b/
-
$GITLAB_FEATURES =~ /\b
container_scanning
\b/
except
:
except
:
variables
:
variables
:
-
$CONTAINER_SCANNING_DISABLED
-
$CONTAINER_SCANNING_DISABLED
...
...
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