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
Tatuya Kamada
gitlab-ce
Commits
17084d42
Commit
17084d42
authored
Jul 15, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify abstract class for CI config entry nodes
parent
4bb60b07
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
43 deletions
+33
-43
lib/gitlab/ci/config/node/configurable.rb
lib/gitlab/ci/config/node/configurable.rb
+7
-5
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+1
-16
lib/gitlab/ci/config/node/global.rb
lib/gitlab/ci/config/node/global.rb
+1
-1
lib/gitlab/ci/config/node/jobs.rb
lib/gitlab/ci/config/node/jobs.rb
+14
-17
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+10
-4
No files found.
lib/gitlab/ci/config/node/configurable.rb
View file @
17084d42
...
@@ -25,12 +25,14 @@ module Gitlab
...
@@ -25,12 +25,14 @@ module Gitlab
private
private
def
create
(
key
,
factory
)
def
compose!
self
.
class
.
nodes
.
each
do
|
key
,
factory
|
factory
factory
.
value
(
@config
[
key
])
.
value
(
@config
[
key
])
.
with
(
key:
key
,
parent:
self
)
.
with
(
key:
key
,
parent:
self
)
factory
.
create!
@entries
[
key
]
=
factory
.
create!
end
end
end
class_methods
do
class_methods
do
...
...
lib/gitlab/ci/config/node/entry.rb
View file @
17084d42
...
@@ -28,11 +28,7 @@ module Gitlab
...
@@ -28,11 +28,7 @@ module Gitlab
end
end
def
leaf?
def
leaf?
nodes
.
none?
@entries
.
none?
end
def
nodes
self
.
class
.
nodes
end
end
def
descendants
def
descendants
...
@@ -74,10 +70,6 @@ module Gitlab
...
@@ -74,10 +70,6 @@ module Gitlab
def
self
.
default
def
self
.
default
end
end
def
self
.
nodes
{}
end
def
self
.
validator
def
self
.
validator
Validator
Validator
end
end
...
@@ -85,13 +77,6 @@ module Gitlab
...
@@ -85,13 +77,6 @@ module Gitlab
private
private
def
compose!
def
compose!
nodes
.
each
do
|
key
,
essence
|
@entries
[
key
]
=
create
(
key
,
essence
)
end
end
def
create
(
entry
,
essence
)
raise
NotImplementedError
end
end
end
end
end
end
...
...
lib/gitlab/ci/config/node/global.rb
View file @
17084d42
...
@@ -47,7 +47,7 @@ module Gitlab
...
@@ -47,7 +47,7 @@ module Gitlab
def
compose_jobs!
def
compose_jobs!
factory
=
Node
::
Factory
.
new
(
Node
::
Jobs
)
factory
=
Node
::
Factory
.
new
(
Node
::
Jobs
)
.
value
(
@config
.
except
(
*
nodes
.
keys
))
.
value
(
@config
.
except
(
*
self
.
class
.
nodes
.
keys
))
.
with
(
key: :jobs
,
parent:
self
,
.
with
(
key: :jobs
,
parent:
self
,
description:
'Jobs definition for this pipeline'
)
description:
'Jobs definition for this pipeline'
)
...
...
lib/gitlab/ci/config/node/jobs.rb
View file @
17084d42
...
@@ -22,27 +22,24 @@ module Gitlab
...
@@ -22,27 +22,24 @@ module Gitlab
end
end
end
end
def
nodes
@config
end
private
private
def
create
(
name
,
config
)
def
compose!
Node
::
Factory
.
new
(
job_class
(
name
))
@config
.
each
do
|
name
,
config
|
node
=
hidden?
(
name
)
?
Node
::
HiddenJob
:
Node
::
Job
factory
=
Node
::
Factory
.
new
(
node
)
.
value
(
config
||
{})
.
value
(
config
||
{})
.
metadata
(
name:
name
)
.
metadata
(
name:
name
)
.
with
(
key:
name
,
parent:
self
,
.
with
(
key:
name
,
parent:
self
,
description:
"
#{
name
}
job definition."
)
description:
"
#{
name
}
job definition."
)
.
create!
end
def
job_class
(
name
)
@entries
[
name
]
=
factory
.
create!
if
name
.
to_s
.
start_with?
(
'.'
)
end
Node
::
HiddenJob
else
Node
::
Job
end
end
def
hidden?
(
name
)
name
.
to_s
.
start_with?
(
'.'
)
end
end
end
end
end
end
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
17084d42
...
@@ -51,13 +51,13 @@ describe Gitlab::Ci::Config::Node::Global do
...
@@ -51,13 +51,13 @@ describe Gitlab::Ci::Config::Node::Global do
expect
(
global
.
descendants
.
second
.
description
)
expect
(
global
.
descendants
.
second
.
description
)
.
to
eq
'Docker image that will be used to execute jobs.'
.
to
eq
'Docker image that will be used to execute jobs.'
end
end
end
describe
'#leaf?'
do
describe
'#leaf?'
do
it
'is not leaf'
do
it
'is not leaf'
do
expect
(
global
).
not_to
be_leaf
expect
(
global
).
not_to
be_leaf
end
end
end
end
end
context
'when not processed'
do
context
'when not processed'
do
describe
'#before_script'
do
describe
'#before_script'
do
...
@@ -65,6 +65,12 @@ describe Gitlab::Ci::Config::Node::Global do
...
@@ -65,6 +65,12 @@ describe Gitlab::Ci::Config::Node::Global do
expect
(
global
.
before_script
).
to
be
nil
expect
(
global
.
before_script
).
to
be
nil
end
end
end
end
describe
'#leaf?'
do
it
'is leaf'
do
expect
(
global
).
to
be_leaf
end
end
end
end
context
'when processed'
do
context
'when processed'
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