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
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
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
22 additions
and
36 deletions
+22
-36
cache.rb
lib/gitlab/ci/config/node/cache.rb
+3
-1
commands.rb
lib/gitlab/ci/config/node/commands.rb
+5
-7
configurable.rb
lib/gitlab/ci/config/node/configurable.rb
+3
-4
global.rb
lib/gitlab/ci/config/node/global.rb
+2
-2
job.rb
lib/gitlab/ci/config/node/job.rb
+2
-2
null.rb
lib/gitlab/ci/config/node/null.rb
+1
-1
trigger.rb
lib/gitlab/ci/config/node/trigger.rb
+2
-2
undefined.rb
lib/gitlab/ci/config/node/undefined.rb
+1
-5
validators.rb
lib/gitlab/ci/config/node/validators.rb
+0
-9
artifacts_spec.rb
spec/lib/gitlab/ci/config/node/artifacts_spec.rb
+1
-1
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
class
Cache
<
Entry
include
Configurable
ALLOWED_KEYS
=
%i[key untracked paths]
validations
do
validates
:config
,
allowed_keys:
%i[key untracked paths]
validates
:config
,
allowed_keys:
ALLOWED_KEYS
end
node
:key
,
Node
::
Key
,
...
...
lib/gitlab/ci/config/node/commands.rb
View file @
a42cce1b
...
...
@@ -11,22 +11,20 @@ module Gitlab
validations
do
include
LegacyValidationHelpers
validate
:string_or_array_of_strings
def
string_or_array_of_strings
unless
config_valid?
validate
do
unless
string_or_array_of_strings?
(
config
)
errors
.
add
(
:config
,
'should be a string or an array of strings'
)
end
end
def
config_valid?
validate_string
(
config
)
||
validate_array_of_strings
(
config
)
def
string_or_array_of_strings?
(
field
)
validate_string
(
field
)
||
validate_array_of_strings
(
field
)
end
end
def
value
[
@config
].
flatten
Array
(
@config
)
end
end
end
...
...
lib/gitlab/ci/config/node/configurable.rb
View file @
a42cce1b
...
...
@@ -56,10 +56,9 @@ module Gitlab
end
define_method
(
"
#{
symbol
}
_value"
)
do
if
@entries
[
symbol
]
return
unless
@entries
[
symbol
].
valid?
@entries
[
symbol
].
value
end
return
unless
@entries
[
symbol
]
&&
@entries
[
symbol
].
valid?
@entries
[
symbol
].
value
end
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
super
compose_jobs!
compose_
stag
es!
compose_
deprecated_entri
es!
end
def
compose_jobs!
...
...
@@ -54,7 +54,7 @@ module Gitlab
@entries
[
:jobs
]
=
factory
.
create!
end
def
compose_
stag
es!
def
compose_
deprecated_entri
es!
##
# Deprecated `:types` key workaround - if types are defined and
# 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
node
:services
,
Services
,
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.'
node
:except
,
While
,
node
:except
,
Trigger
,
description:
'Refs policy this job will be executed for.'
node
:variables
,
Variables
,
...
...
lib/gitlab/ci/config/node/null.rb
View file @
a42cce1b
...
...
@@ -3,7 +3,7 @@ module Gitlab
class
Config
module
Node
##
# This class represents an undefined
and unspecified
node.
# This class represents an undefined node.
#
# 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
class
Config
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
validations
do
...
...
lib/gitlab/ci/config/node/undefined.rb
View file @
a42cce1b
...
...
@@ -3,16 +3,12 @@ module Gitlab
class
Config
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
# unspecified.
#
class
Undefined
<
SimpleDelegator
def
initialize
(
entry
)
super
end
def
specified?
false
end
...
...
lib/gitlab/ci/config/node/validators.rb
View file @
a42cce1b
...
...
@@ -44,15 +44,6 @@ module Gitlab
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
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
let
(
:config
)
{
{
paths:
%w[public/]
}
}
describe
'#value'
do
it
'returns
image string
'
do
it
'returns
artifacs configuration
'
do
expect
(
entry
.
value
).
to
eq
config
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'
describe
Gitlab
::
Ci
::
Config
::
Node
::
While
do
describe
Gitlab
::
Ci
::
Config
::
Node
::
Trigger
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
...
...
@@ -48,7 +48,7 @@ describe Gitlab::Ci::Config::Node::While do
describe
'#errors'
do
it
'saves errors'
do
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
...
...
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