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
dd784b15
Commit
dd784b15
authored
Sep 14, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use CI/CD job policy specification in YAML processor
parent
59f87e73
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
9 deletions
+26
-9
lib/gitlab/ci/build/policy.rb
lib/gitlab/ci/build/policy.rb
+19
-0
lib/gitlab/ci/build/policy/specification.rb
lib/gitlab/ci/build/policy/specification.rb
+0
-3
lib/gitlab/ci/yaml_processor.rb
lib/gitlab/ci/yaml_processor.rb
+7
-6
No files found.
lib/gitlab/ci/build/policy.rb
0 → 100644
View file @
dd784b15
module
Gitlab
module
Ci
module
Build
module
Policy
def
self
.
fabricate
(
specs
)
specifications
=
specs
.
to_h
.
map
do
|
spec
,
value
|
begin
self
.
const_get
(
spec
.
to_s
.
camelize
).
new
(
value
)
rescue
NameError
next
end
end
specifications
.
compact
end
end
end
end
end
lib/gitlab/ci/build/policy/specification.rb
View file @
dd784b15
...
@@ -18,9 +18,6 @@ module Gitlab
...
@@ -18,9 +18,6 @@ module Gitlab
def
satisfied_by?
(
pipeline
,
**
metadata
)
def
satisfied_by?
(
pipeline
,
**
metadata
)
raise
NotImplementedError
raise
NotImplementedError
end
end
def
self
.
fabricate_all
(
*
specs
)
end
end
end
end
end
end
end
...
...
lib/gitlab/ci/yaml_processor.rb
View file @
dd784b15
...
@@ -89,13 +89,14 @@ module Gitlab
...
@@ -89,13 +89,14 @@ module Gitlab
builds
.
select
do
|
build
|
builds
.
select
do
|
build
|
job
=
@jobs
[
build
.
fetch
(
:name
).
to_sym
]
job
=
@jobs
[
build
.
fetch
(
:name
).
to_sym
]
has_kubernetes
=
pipeline
.
has_kubernetes_active?
only_kubernetes
=
job
.
dig
(
:only
,
:kubernetes
)
except_kubernetes
=
job
.
dig
(
:except
,
:kubernetes
)
[
!
only_kubernetes
&&
!
except_kubernetes
,
only_specs
=
Gitlab
::
Ci
::
Build
::
Policy
only_kubernetes
&&
has_kubernetes
,
.
fabricate
(
job
.
fetch
(
:only
,
{}))
except_kubernetes
&&
!
has_kubernetes
].
any?
except_specs
=
Gitlab
::
Ci
::
Build
::
Policy
.
fabricate
(
job
.
fetch
(
:except
,
{}))
only_specs
.
all?
{
|
spec
|
spec
.
satisfied_by?
(
pipeline
)
}
&&
except_specs
.
none?
{
|
spec
|
spec
.
satisfied_by?
(
pipeline
)
}
end
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