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
iv
gitlab-ce
Commits
12080ba1
Commit
12080ba1
authored
Jun 10, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify new ci config entry class interface
parent
828a15bc
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
62 deletions
+44
-62
lib/gitlab/ci/config/node/configurable.rb
lib/gitlab/ci/config/node/configurable.rb
+3
-3
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+3
-12
lib/gitlab/ci/config/node/null.rb
lib/gitlab/ci/config/node/null.rb
+6
-6
lib/gitlab/ci/config/node/script.rb
lib/gitlab/ci/config/node/script.rb
+2
-2
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+0
-12
spec/lib/gitlab/ci/config/node/null_spec.rb
spec/lib/gitlab/ci/config/node/null_spec.rb
+1
-1
spec/lib/gitlab/ci/config/node/script_spec.rb
spec/lib/gitlab/ci/config/node/script_spec.rb
+29
-26
No files found.
lib/gitlab/ci/config/node/configurable.rb
View file @
12080ba1
...
...
@@ -19,7 +19,7 @@ module Gitlab
def
initialize
(
*
)
super
unless
leaf?
||
has_config?
unless
@value
.
is_a?
(
Hash
)
@errors
<<
'should be a configuration entry with hash value'
end
end
...
...
@@ -39,9 +39,9 @@ module Gitlab
def
create_entry
(
key
,
entry_class
)
if
@value
.
has_key?
(
key
)
entry_class
.
new
(
@value
[
key
]
,
@root
,
self
)
entry_class
.
new
(
@value
[
key
])
else
Node
::
Null
.
new
(
nil
,
@root
,
self
)
Node
::
Null
.
new
(
nil
)
end
end
...
...
lib/gitlab/ci/config/node/entry.rb
View file @
12080ba1
...
...
@@ -10,16 +10,15 @@ module Gitlab
attr_accessor
:description
def
initialize
(
value
,
root
=
nil
,
parent
=
nil
)
def
initialize
(
value
)
@value
=
value
@root
=
root
@parent
=
parent
@nodes
=
{}
@errors
=
[]
end
def
process!
return
if
leaf?
||
invalid?
return
if
leaf?
return
unless
valid?
compose!
...
...
@@ -41,18 +40,10 @@ module Gitlab
errors
.
none?
end
def
invalid?
!
valid?
end
def
leaf?
allowed_nodes
.
none?
end
def
has_config?
@value
.
is_a?
(
Hash
)
end
def
errors
@errors
+
nodes
.
map
(
&
:errors
).
flatten
end
...
...
lib/gitlab/ci/config/node/null.rb
View file @
12080ba1
module
Gitlab
module
Ci
class
Config
module
Node
##
# This class represents a configuration entry that is not being used
# in configuration file.
#
# This implements Null Object pattern.
#
module
Node
class
Null
<
Entry
def
value
nil
...
...
lib/gitlab/ci/config/node/script.rb
View file @
12080ba1
...
...
@@ -6,8 +6,8 @@ module Gitlab
# Entry that represents a script.
#
# Each element in the value array is a command that will be executed
# by GitLab Runner. Currently we concatenate th
is
commands with
# new line character as a separator
what is compatbi
le with
# by GitLab Runner. Currently we concatenate th
ese
commands with
# new line character as a separator
, what is compatib
le with
# implementation in Runner.
#
class
Script
<
Entry
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
12080ba1
...
...
@@ -49,12 +49,6 @@ describe Gitlab::Ci::Config::Node::Global do
end
end
describe
'#has_config?'
do
it
'has config'
do
expect
(
global
).
to
have_config
end
end
describe
'#leaf?'
do
it
'is not leaf'
do
expect
(
global
).
not_to
be_leaf
...
...
@@ -91,12 +85,6 @@ describe Gitlab::Ci::Config::Node::Global do
end
end
describe
'#invalid?'
do
it
'is not valid'
do
expect
(
global
).
to
be_invalid
end
end
describe
'#errors'
do
it
'reports errors from child nodes'
do
expect
(
global
.
errors
)
...
...
spec/lib/gitlab/ci/config/node/null_spec.rb
View file @
12080ba1
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Null
do
let
(
:entry
)
{
described_class
.
new
(
double
,
double
)
}
let
(
:entry
)
{
described_class
.
new
(
nil
)
}
describe
'#leaf?'
do
it
'is leaf node'
do
...
...
spec/lib/gitlab/ci/config/node/script_spec.rb
View file @
12080ba1
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Script
do
let
(
:entry
)
{
described_class
.
new
(
value
,
double
)}
let
(
:entry
)
{
described_class
.
new
(
value
)
}
describe
'#validate!'
do
before
{
entry
.
validate!
}
context
'when entry value is correct'
do
...
...
@@ -19,9 +21,9 @@ describe Gitlab::Ci::Config::Node::Script do
end
end
describe
'#has_config
?'
do
it
'does not have config
'
do
expect
(
entry
).
not_to
have_config
describe
'#valid
?'
do
it
'is valid
'
do
expect
(
entry
).
to
be_valid
end
end
end
...
...
@@ -36,9 +38,10 @@ describe Gitlab::Ci::Config::Node::Script do
end
end
describe
'#in
valid?'
do
describe
'#
valid?'
do
it
'is not valid'
do
expect
(
entry
).
to
be_invalid
expect
(
entry
).
not_to
be_valid
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