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
0335d09e
Commit
0335d09e
authored
Mar 23, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate variables policy with new pipeline services
parent
f2ec6c1c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
14 deletions
+14
-14
lib/gitlab/ci/build/policy/kubernetes.rb
lib/gitlab/ci/build/policy/kubernetes.rb
+1
-1
lib/gitlab/ci/build/policy/refs.rb
lib/gitlab/ci/build/policy/refs.rb
+1
-1
lib/gitlab/ci/build/policy/specification.rb
lib/gitlab/ci/build/policy/specification.rb
+1
-1
lib/gitlab/ci/build/policy/variables.rb
lib/gitlab/ci/build/policy/variables.rb
+1
-1
lib/gitlab/ci/pipeline/expression/statement.rb
lib/gitlab/ci/pipeline/expression/statement.rb
+3
-3
spec/lib/gitlab/ci/build/policy/variables_spec.rb
spec/lib/gitlab/ci/build/policy/variables_spec.rb
+7
-7
No files found.
lib/gitlab/ci/build/policy/kubernetes.rb
View file @
0335d09e
...
...
@@ -9,7 +9,7 @@ module Gitlab
end
end
def
satisfied_by?
(
pipeline
,
_
attributes
=
nil
)
def
satisfied_by?
(
pipeline
,
_
build
=
nil
)
pipeline
.
has_kubernetes_active?
end
end
...
...
lib/gitlab/ci/build/policy/refs.rb
View file @
0335d09e
...
...
@@ -7,7 +7,7 @@ module Gitlab
@patterns
=
Array
(
refs
)
end
def
satisfied_by?
(
pipeline
,
_
attributes
=
nil
)
def
satisfied_by?
(
pipeline
,
_
build
=
nil
)
@patterns
.
any?
do
|
pattern
|
pattern
,
path
=
pattern
.
split
(
'@'
,
2
)
...
...
lib/gitlab/ci/build/policy/specification.rb
View file @
0335d09e
...
...
@@ -15,7 +15,7 @@ module Gitlab
@spec
=
spec
end
def
satisfied_by?
(
pipeline
,
attributes
=
nil
)
def
satisfied_by?
(
pipeline
,
build
=
nil
)
raise
NotImplementedError
end
end
...
...
lib/gitlab/ci/build/policy/variables.rb
View file @
0335d09e
...
...
@@ -7,7 +7,7 @@ module Gitlab
@expressions
=
Array
(
expressions
)
end
def
satisfied_by?
(
pipeline
,
attributes
)
def
satisfied_by?
(
pipeline
,
build
)
statements
=
@expressions
.
map
do
|
statement
|
::
Gitlab
::
Ci
::
Pipeline
::
Expression
::
Statement
.
new
(
statement
,
pipeline
)
...
...
lib/gitlab/ci/pipeline/expression/statement.rb
View file @
0335d09e
...
...
@@ -19,10 +19,10 @@ module Gitlab
return
if
pipeline
.
nil?
# temporary refactoring stubs
#
REFACTORING,
temporary refactoring stubs
#
@variables
=
pipeline
.
project
.
predefined_variables
.
map
do
|
variable
|
[
variable
.
fetch
(
:key
),
variable
.
fetch
(
:value
)
]
[
variable
[
:key
],
variable
[
:value
]
]
end
@variables
+=
pipeline
.
variables
.
map
do
|
variable
|
...
...
@@ -30,7 +30,7 @@ module Gitlab
end
@variables
+=
pipeline
.
predefined_variables
.
map
do
|
variable
|
[
variable
.
fetch
(
:key
),
variable
.
fetch
(
:value
)
]
[
variable
[
:key
],
variable
[
:value
]
]
end
end
...
...
spec/lib/gitlab/ci/build/policy/variables_spec.rb
View file @
0335d09e
require
'spec_helper'
describe
Gitlab
::
Ci
::
Build
::
Policy
::
Variables
do
let
(
:pipeline
)
{
build
(
:ci
_pipeline
,
ref:
'master'
)
}
let
(
:
attributes
)
{
double
(
:attributes
)
}
let
(
:pipeline
)
{
build
_stubbed
(
:ci_empty
_pipeline
,
ref:
'master'
)
}
let
(
:
build
)
{
build_stubbed
(
:ci_build
,
pipeline:
pipeline
,
ref:
'master'
)
}
before
do
pipeline
.
variables
.
build
(
key:
'CI_PROJECT_NAME'
,
value:
''
)
...
...
@@ -12,31 +12,31 @@ describe Gitlab::Ci::Build::Policy::Variables do
it
'is satisfied by a defined and existing variable'
do
policy
=
described_class
.
new
([
'$CI_PROJECT_ID'
,
'$UNDEFINED'
])
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
attributes
)
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
build
)
end
it
'is not satisfied by an overriden empty variable'
do
policy
=
described_class
.
new
([
'$CI_PROJECT_NAME'
])
expect
(
policy
).
not_to
be_satisfied_by
(
pipeline
,
attributes
)
expect
(
policy
).
not_to
be_satisfied_by
(
pipeline
,
build
)
end
it
'is satisfied by a truthy pipeline expression'
do
policy
=
described_class
.
new
([
%($CI_PIPELINE_SOURCE == "#{pipeline.source}")
])
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
attributes
)
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
build
)
end
it
'is not satisfied by a falsy pipeline expression'
do
policy
=
described_class
.
new
([
%($CI_PIPELINE_SOURCE == "invalid source")
])
expect
(
policy
).
not_to
be_satisfied_by
(
pipeline
,
attributes
)
expect
(
policy
).
not_to
be_satisfied_by
(
pipeline
,
build
)
end
it
'is satisfied by a truthy expression using undefined variable'
do
policy
=
described_class
.
new
([
'$UNDEFINED'
,
'$UNDEFINED == null'
])
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
attributes
)
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
build
)
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