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
a42cce1b
Commit
a42cce1b
authored
Jul 29, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve code, remove unused validator, improve names
parent
69dad967
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
22 additions
and
36 deletions
+22
-36
lib/gitlab/ci/config/node/cache.rb
lib/gitlab/ci/config/node/cache.rb
+3
-1
lib/gitlab/ci/config/node/commands.rb
lib/gitlab/ci/config/node/commands.rb
+5
-7
lib/gitlab/ci/config/node/configurable.rb
lib/gitlab/ci/config/node/configurable.rb
+3
-4
lib/gitlab/ci/config/node/global.rb
lib/gitlab/ci/config/node/global.rb
+2
-2
lib/gitlab/ci/config/node/job.rb
lib/gitlab/ci/config/node/job.rb
+2
-2
lib/gitlab/ci/config/node/null.rb
lib/gitlab/ci/config/node/null.rb
+1
-1
lib/gitlab/ci/config/node/trigger.rb
lib/gitlab/ci/config/node/trigger.rb
+2
-2
lib/gitlab/ci/config/node/undefined.rb
lib/gitlab/ci/config/node/undefined.rb
+1
-5
lib/gitlab/ci/config/node/validators.rb
lib/gitlab/ci/config/node/validators.rb
+0
-9
spec/lib/gitlab/ci/config/node/artifacts_spec.rb
spec/lib/gitlab/ci/config/node/artifacts_spec.rb
+1
-1
spec/lib/gitlab/ci/config/node/trigger_spec.rb
spec/lib/gitlab/ci/config/node/trigger_spec.rb
+2
-2
No files found.
lib/gitlab/ci/config/node/cache.rb
View file @
a42cce1b
...
@@ -8,8 +8,10 @@ module Gitlab
...
@@ -8,8 +8,10 @@ module Gitlab
class
Cache
<
Entry
class
Cache
<
Entry
include
Configurable
include
Configurable
ALLOWED_KEYS
=
%i[key untracked paths]
validations
do
validations
do
validates
:config
,
allowed_keys:
%i[key untracked paths]
validates
:config
,
allowed_keys:
ALLOWED_KEYS
end
end
node
:key
,
Node
::
Key
,
node
:key
,
Node
::
Key
,
...
...
lib/gitlab/ci/config/node/commands.rb
View file @
a42cce1b
...
@@ -11,22 +11,20 @@ module Gitlab
...
@@ -11,22 +11,20 @@ module Gitlab
validations
do
validations
do
include
LegacyValidationHelpers
include
LegacyValidationHelpers
validate
:string_or_array_of_strings
validate
do
unless
string_or_array_of_strings?
(
config
)
def
string_or_array_of_strings
unless
config_valid?
errors
.
add
(
:config
,
errors
.
add
(
:config
,
'should be a string or an array of strings'
)
'should be a string or an array of strings'
)
end
end
end
end
def
config_valid?
def
string_or_array_of_strings?
(
field
)
validate_string
(
config
)
||
validate_array_of_strings
(
config
)
validate_string
(
field
)
||
validate_array_of_strings
(
field
)
end
end
end
end
def
value
def
value
[
@config
].
flatten
Array
(
@config
)
end
end
end
end
end
end
...
...
lib/gitlab/ci/config/node/configurable.rb
View file @
a42cce1b
...
@@ -56,10 +56,9 @@ module Gitlab
...
@@ -56,10 +56,9 @@ module Gitlab
end
end
define_method
(
"
#{
symbol
}
_value"
)
do
define_method
(
"
#{
symbol
}
_value"
)
do
if
@entries
[
symbol
]
return
unless
@entries
[
symbol
]
&&
@entries
[
symbol
].
valid?
return
unless
@entries
[
symbol
].
valid?
@entries
[
symbol
].
value
@entries
[
symbol
].
value
end
end
end
alias_method
symbol
.
to_sym
,
"
#{
symbol
}
_value"
.
to_sym
alias_method
symbol
.
to_sym
,
"
#{
symbol
}
_value"
.
to_sym
...
...
lib/gitlab/ci/config/node/global.rb
View file @
a42cce1b
...
@@ -42,7 +42,7 @@ module Gitlab
...
@@ -42,7 +42,7 @@ module Gitlab
super
super
compose_jobs!
compose_jobs!
compose_
stag
es!
compose_
deprecated_entri
es!
end
end
def
compose_jobs!
def
compose_jobs!
...
@@ -54,7 +54,7 @@ module Gitlab
...
@@ -54,7 +54,7 @@ module Gitlab
@entries
[
:jobs
]
=
factory
.
create!
@entries
[
:jobs
]
=
factory
.
create!
end
end
def
compose_
stag
es!
def
compose_
deprecated_entri
es!
##
##
# Deprecated `:types` key workaround - if types are defined and
# Deprecated `:types` key workaround - if types are defined and
# stages are not defined we use types definition as stages.
# stages are not defined we use types definition as stages.
...
...
lib/gitlab/ci/config/node/job.rb
View file @
a42cce1b
...
@@ -66,10 +66,10 @@ module Gitlab
...
@@ -66,10 +66,10 @@ module Gitlab
node
:services
,
Services
,
node
:services
,
Services
,
description:
'Services that will be used to execute this job.'
description:
'Services that will be used to execute this job.'
node
:only
,
While
,
node
:only
,
Trigger
,
description:
'Refs policy this job will be executed for.'
description:
'Refs policy this job will be executed for.'
node
:except
,
While
,
node
:except
,
Trigger
,
description:
'Refs policy this job will be executed for.'
description:
'Refs policy this job will be executed for.'
node
:variables
,
Variables
,
node
:variables
,
Variables
,
...
...
lib/gitlab/ci/config/node/null.rb
View file @
a42cce1b
...
@@ -3,7 +3,7 @@ module Gitlab
...
@@ -3,7 +3,7 @@ module Gitlab
class
Config
class
Config
module
Node
module
Node
##
##
# This class represents an undefined
and unspecified
node.
# This class represents an undefined node.
#
#
# Implements the Null Object pattern.
# Implements the Null Object pattern.
#
#
...
...
lib/gitlab/ci/config/node/
while
.rb
→
lib/gitlab/ci/config/node/
trigger
.rb
View file @
a42cce1b
...
@@ -3,9 +3,9 @@ module Gitlab
...
@@ -3,9 +3,9 @@ module Gitlab
class
Config
class
Config
module
Node
module
Node
##
##
# Entry that represents a
ref and
trigger policy for the job.
# Entry that represents a trigger policy for the job.
#
#
class
While
<
Entry
class
Trigger
<
Entry
include
Validatable
include
Validatable
validations
do
validations
do
...
...
lib/gitlab/ci/config/node/undefined.rb
View file @
a42cce1b
...
@@ -3,16 +3,12 @@ module Gitlab
...
@@ -3,16 +3,12 @@ module Gitlab
class
Config
class
Config
module
Node
module
Node
##
##
# This class represents an un
defined and un
specified entry node.
# This class represents an unspecified entry node.
#
#
# It decorates original entry adding method that indicates it is
# It decorates original entry adding method that indicates it is
# unspecified.
# unspecified.
#
#
class
Undefined
<
SimpleDelegator
class
Undefined
<
SimpleDelegator
def
initialize
(
entry
)
super
end
def
specified?
def
specified?
false
false
end
end
...
...
lib/gitlab/ci/config/node/validators.rb
View file @
a42cce1b
...
@@ -44,15 +44,6 @@ module Gitlab
...
@@ -44,15 +44,6 @@ module Gitlab
end
end
end
end
class
RequiredValidator
<
ActiveModel
::
EachValidator
def
validate_each
(
record
,
attribute
,
value
)
if
value
.
nil?
raise
Entry
::
InvalidError
,
"Entry needs
#{
attribute
}
attribute set internally."
end
end
end
class
KeyValidator
<
ActiveModel
::
EachValidator
class
KeyValidator
<
ActiveModel
::
EachValidator
include
LegacyValidationHelpers
include
LegacyValidationHelpers
...
...
spec/lib/gitlab/ci/config/node/artifacts_spec.rb
View file @
a42cce1b
...
@@ -8,7 +8,7 @@ describe Gitlab::Ci::Config::Node::Artifacts do
...
@@ -8,7 +8,7 @@ describe Gitlab::Ci::Config::Node::Artifacts do
let
(
:config
)
{
{
paths:
%w[public/]
}
}
let
(
:config
)
{
{
paths:
%w[public/]
}
}
describe
'#value'
do
describe
'#value'
do
it
'returns
image string
'
do
it
'returns
artifacs configuration
'
do
expect
(
entry
.
value
).
to
eq
config
expect
(
entry
.
value
).
to
eq
config
end
end
end
end
...
...
spec/lib/gitlab/ci/config/node/
while
_spec.rb
→
spec/lib/gitlab/ci/config/node/
trigger
_spec.rb
View file @
a42cce1b
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
While
do
describe
Gitlab
::
Ci
::
Config
::
Node
::
Trigger
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
describe
'validations'
do
...
@@ -48,7 +48,7 @@ describe Gitlab::Ci::Config::Node::While do
...
@@ -48,7 +48,7 @@ describe Gitlab::Ci::Config::Node::While do
describe
'#errors'
do
describe
'#errors'
do
it
'saves errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
expect
(
entry
.
errors
)
.
to
include
'
while
config should be an array of strings or regexps'
.
to
include
'
trigger
config should be an array of strings or regexps'
end
end
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