BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
9edced40
Commit
9edced40
authored
Jul 09, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use node factory to assemble global CI config entry
parent
ccbdb402
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
17 deletions
+25
-17
configurable.rb
lib/gitlab/ci/config/node/configurable.rb
+2
-2
global.rb
lib/gitlab/ci/config/node/global.rb
+21
-13
global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+2
-2
No files found.
lib/gitlab/ci/config/node/configurable.rb
View file @
9edced40
...
...
@@ -27,8 +27,8 @@ module Gitlab
def
create
(
key
,
factory
)
factory
.
value
(
config
[
key
])
.
with
(
key:
key
,
parent:
self
,
global:
global
)
.
value
(
@
config
[
key
])
.
with
(
key:
key
,
parent:
self
,
global:
@
global
)
factory
.
create!
end
...
...
lib/gitlab/ci/config/node/global.rb
View file @
9edced40
...
...
@@ -33,30 +33,38 @@ module Gitlab
node
:cache
,
Node
::
Cache
,
description:
'Configure caching between build jobs.'
node
:jobs
,
Node
::
Jobs
,
description:
'Definition of jobs for this pipeline.'
helpers
:before_script
,
:image
,
:services
,
:after_script
,
:variables
,
:stages
,
:types
,
:cache
,
:jobs
def
initialize
(
config
,
**
attributes
)
super
(
setup
(
config
),
attributes
)
def
initialize
(
*
)
super
@global
=
self
end
def
stages
stages_defined?
?
stages_value
:
types_value
private
def
compose!
super
compose_stages!
compose_jobs!
end
private
def
compose_stages!
factory
=
Node
::
Factory
.
new
(
Node
::
Jobs
)
factory
.
value
(
@config
.
except
(
*
nodes
.
keys
))
factory
.
with
(
key: :jobs
,
parent:
self
,
global:
self
)
factory
.
with
(
description:
'Jobs definition for this pipeline'
)
def
setup
(
config
)
return
config
unless
config
.
is_a?
(
Hash
)
@entries
[
:jobs
]
=
factory
.
create!
end
jobs
=
config
.
except
(
*
nodes
.
keys
)
global
=
config
.
slice
(
*
nodes
.
keys
)
def
compose_jobs!
if
types_defined?
&&
!
stages_defined?
@entries
[
:stages
]
=
@entries
[
:types
]
end
global
.
merge
(
jobs:
job
s
)
@entries
.
delete
(
:type
s
)
end
end
end
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
9edced40
...
...
@@ -35,7 +35,7 @@ describe Gitlab::Ci::Config::Node::Global do
end
it
'creates node object for each entry'
do
expect
(
global
.
descendants
.
count
).
to
eq
9
expect
(
global
.
descendants
.
count
).
to
eq
8
end
it
'creates node object using valid class'
do
...
...
@@ -142,7 +142,7 @@ describe Gitlab::Ci::Config::Node::Global do
describe
'#nodes'
do
it
'instantizes all nodes'
do
expect
(
global
.
descendants
.
count
).
to
eq
9
expect
(
global
.
descendants
.
count
).
to
eq
8
end
it
'contains undefined nodes'
do
...
...
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