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
c7014683
Commit
c7014683
authored
Nov 14, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve naming convention in ci configuration module
parent
b44237f5
Changes
55
Show whitespace changes
Inline
Side-by-side
Showing
55 changed files
with
166 additions
and
168 deletions
+166
-168
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+1
-1
lib/gitlab/ci/config.rb
lib/gitlab/ci/config.rb
+1
-1
lib/gitlab/ci/config/entry/artifacts.rb
lib/gitlab/ci/config/entry/artifacts.rb
+2
-2
lib/gitlab/ci/config/entry/attributable.rb
lib/gitlab/ci/config/entry/attributable.rb
+1
-1
lib/gitlab/ci/config/entry/boolean.rb
lib/gitlab/ci/config/entry/boolean.rb
+2
-2
lib/gitlab/ci/config/entry/cache.rb
lib/gitlab/ci/config/entry/cache.rb
+5
-5
lib/gitlab/ci/config/entry/commands.rb
lib/gitlab/ci/config/entry/commands.rb
+2
-2
lib/gitlab/ci/config/entry/configurable.rb
lib/gitlab/ci/config/entry/configurable.rb
+2
-2
lib/gitlab/ci/config/entry/environment.rb
lib/gitlab/ci/config/entry/environment.rb
+2
-2
lib/gitlab/ci/config/entry/factory.rb
lib/gitlab/ci/config/entry/factory.rb
+15
-15
lib/gitlab/ci/config/entry/global.rb
lib/gitlab/ci/config/entry/global.rb
+12
-12
lib/gitlab/ci/config/entry/hidden.rb
lib/gitlab/ci/config/entry/hidden.rb
+3
-3
lib/gitlab/ci/config/entry/image.rb
lib/gitlab/ci/config/entry/image.rb
+2
-2
lib/gitlab/ci/config/entry/job.rb
lib/gitlab/ci/config/entry/job.rb
+15
-15
lib/gitlab/ci/config/entry/jobs.rb
lib/gitlab/ci/config/entry/jobs.rb
+4
-4
lib/gitlab/ci/config/entry/key.rb
lib/gitlab/ci/config/entry/key.rb
+2
-2
lib/gitlab/ci/config/entry/legacy_validation_helpers.rb
lib/gitlab/ci/config/entry/legacy_validation_helpers.rb
+1
-1
lib/gitlab/ci/config/entry/node.rb
lib/gitlab/ci/config/entry/node.rb
+3
-3
lib/gitlab/ci/config/entry/paths.rb
lib/gitlab/ci/config/entry/paths.rb
+2
-2
lib/gitlab/ci/config/entry/script.rb
lib/gitlab/ci/config/entry/script.rb
+2
-2
lib/gitlab/ci/config/entry/services.rb
lib/gitlab/ci/config/entry/services.rb
+2
-2
lib/gitlab/ci/config/entry/stage.rb
lib/gitlab/ci/config/entry/stage.rb
+2
-2
lib/gitlab/ci/config/entry/stages.rb
lib/gitlab/ci/config/entry/stages.rb
+2
-2
lib/gitlab/ci/config/entry/trigger.rb
lib/gitlab/ci/config/entry/trigger.rb
+2
-2
lib/gitlab/ci/config/entry/undefined.rb
lib/gitlab/ci/config/entry/undefined.rb
+3
-5
lib/gitlab/ci/config/entry/unspecified.rb
lib/gitlab/ci/config/entry/unspecified.rb
+2
-2
lib/gitlab/ci/config/entry/validatable.rb
lib/gitlab/ci/config/entry/validatable.rb
+2
-2
lib/gitlab/ci/config/entry/validator.rb
lib/gitlab/ci/config/entry/validator.rb
+6
-6
lib/gitlab/ci/config/entry/validators.rb
lib/gitlab/ci/config/entry/validators.rb
+1
-1
lib/gitlab/ci/config/entry/variables.rb
lib/gitlab/ci/config/entry/variables.rb
+2
-2
spec/lib/gitlab/ci/config/entry/artifacts_spec.rb
spec/lib/gitlab/ci/config/entry/artifacts_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/attributable_spec.rb
spec/lib/gitlab/ci/config/entry/attributable_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/boolean_spec.rb
spec/lib/gitlab/ci/config/entry/boolean_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/cache_spec.rb
spec/lib/gitlab/ci/config/entry/cache_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/commands_spec.rb
spec/lib/gitlab/ci/config/entry/commands_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/configurable_spec.rb
spec/lib/gitlab/ci/config/entry/configurable_spec.rb
+15
-15
spec/lib/gitlab/ci/config/entry/environment_spec.rb
spec/lib/gitlab/ci/config/entry/environment_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/factory_spec.rb
spec/lib/gitlab/ci/config/entry/factory_spec.rb
+7
-7
spec/lib/gitlab/ci/config/entry/global_spec.rb
spec/lib/gitlab/ci/config/entry/global_spec.rb
+5
-5
spec/lib/gitlab/ci/config/entry/hidden_spec.rb
spec/lib/gitlab/ci/config/entry/hidden_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/image_spec.rb
spec/lib/gitlab/ci/config/entry/image_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/job_spec.rb
spec/lib/gitlab/ci/config/entry/job_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/jobs_spec.rb
spec/lib/gitlab/ci/config/entry/jobs_spec.rb
+3
-3
spec/lib/gitlab/ci/config/entry/key_spec.rb
spec/lib/gitlab/ci/config/entry/key_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/paths_spec.rb
spec/lib/gitlab/ci/config/entry/paths_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/script_spec.rb
spec/lib/gitlab/ci/config/entry/script_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/services_spec.rb
spec/lib/gitlab/ci/config/entry/services_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/stage_spec.rb
spec/lib/gitlab/ci/config/entry/stage_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/stages_spec.rb
spec/lib/gitlab/ci/config/entry/stages_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/trigger_spec.rb
spec/lib/gitlab/ci/config/entry/trigger_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/undefined_spec.rb
spec/lib/gitlab/ci/config/entry/undefined_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/unspecified_spec.rb
spec/lib/gitlab/ci/config/entry/unspecified_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/validatable_spec.rb
spec/lib/gitlab/ci/config/entry/validatable_spec.rb
+13
-13
spec/lib/gitlab/ci/config/entry/validator_spec.rb
spec/lib/gitlab/ci/config/entry/validator_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/variables_spec.rb
spec/lib/gitlab/ci/config/entry/variables_spec.rb
+1
-1
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
c7014683
...
...
@@ -2,7 +2,7 @@ module Ci
class
GitlabCiYamlProcessor
class
ValidationError
<
StandardError
;
end
include
Gitlab
::
Ci
::
Config
::
Node
::
LegacyValidationHelpers
include
Gitlab
::
Ci
::
Config
::
Entry
::
LegacyValidationHelpers
attr_reader
:path
,
:cache
,
:stages
,
:jobs
...
...
lib/gitlab/ci/config.rb
View file @
c7014683
...
...
@@ -13,7 +13,7 @@ module Gitlab
def
initialize
(
config
)
@config
=
Loader
.
new
(
config
).
load!
@global
=
Node
::
Global
.
new
(
@config
)
@global
=
Entry
::
Global
.
new
(
@config
)
@global
.
compose!
end
...
...
lib/gitlab/ci/config/
node
/artifacts.rb
→
lib/gitlab/ci/config/
entry
/artifacts.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents a configuration of job artifacts.
#
class
Artifacts
<
Entry
class
Artifacts
<
Node
include
Validatable
include
Attributable
...
...
lib/gitlab/ci/config/
node
/attributable.rb
→
lib/gitlab/ci/config/
entry
/attributable.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
module
Attributable
extend
ActiveSupport
::
Concern
...
...
lib/gitlab/ci/config/
node
/boolean.rb
→
lib/gitlab/ci/config/
entry
/boolean.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents a boolean value.
#
class
Boolean
<
Entry
class
Boolean
<
Node
include
Validatable
validations
do
...
...
lib/gitlab/ci/config/
node
/cache.rb
→
lib/gitlab/ci/config/
entry
/cache.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents a cache configuration
#
class
Cache
<
Entry
class
Cache
<
Node
include
Configurable
ALLOWED_KEYS
=
%i[key untracked paths]
...
...
@@ -14,13 +14,13 @@ module Gitlab
validates
:config
,
allowed_keys:
ALLOWED_KEYS
end
node
:key
,
Node
::
Key
,
node
:key
,
Entry
::
Key
,
description:
'Cache key used to define a cache affinity.'
node
:untracked
,
Node
::
Boolean
,
node
:untracked
,
Entry
::
Boolean
,
description:
'Cache all untracked files.'
node
:paths
,
Node
::
Paths
,
node
:paths
,
Entry
::
Paths
,
description:
'Specify which paths should be cached across builds.'
end
end
...
...
lib/gitlab/ci/config/
node
/commands.rb
→
lib/gitlab/ci/config/
entry
/commands.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents a job script.
#
class
Commands
<
Entry
class
Commands
<
Node
include
Validatable
validations
do
...
...
lib/gitlab/ci/config/
node
/configurable.rb
→
lib/gitlab/ci/config/
entry
/configurable.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# This mixin is responsible for adding DSL, which purpose is to
# simplifly process of adding child nodes.
...
...
@@ -49,7 +49,7 @@ module Gitlab
private
# rubocop:disable Lint/UselessAccessModifier
def
node
(
key
,
node
,
metadata
)
factory
=
Node
::
Factory
.
new
(
node
)
factory
=
Entry
::
Factory
.
new
(
node
)
.
with
(
description:
metadata
[
:description
])
(
@nodes
||=
{}).
merge!
(
key
.
to_sym
=>
factory
)
...
...
lib/gitlab/ci/config/
node
/environment.rb
→
lib/gitlab/ci/config/
entry
/environment.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents an environment.
#
class
Environment
<
Entry
class
Environment
<
Node
include
Validatable
ALLOWED_KEYS
=
%i[name url action on_stop]
...
...
lib/gitlab/ci/config/
node
/factory.rb
→
lib/gitlab/ci/config/
entry
/factory.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Factory class responsible for fabricating
node
entry objects.
# Factory class responsible for fabricating entry objects.
#
class
Factory
class
InvalidFactory
<
StandardError
;
end
def
initialize
(
node
)
@
node
=
node
def
initialize
(
entry
)
@
entry
=
entry
@metadata
=
{}
@attributes
=
{}
end
...
...
@@ -37,11 +37,11 @@ module Gitlab
# See issue #18775.
#
if
@value
.
nil?
Node
::
Unspecified
.
new
(
Entry
::
Unspecified
.
new
(
fabricate_unspecified
)
else
fabricate
(
@
node
,
@value
)
fabricate
(
@
entry
,
@value
)
end
end
...
...
@@ -49,21 +49,21 @@ module Gitlab
def
fabricate_unspecified
##
# If
node
has a default value we fabricate concrete node
# If
entry
has a default value we fabricate concrete node
# with default value.
#
if
@
node
.
default
.
nil?
fabricate
(
Node
::
Undefined
)
if
@
entry
.
default
.
nil?
fabricate
(
Entry
::
Undefined
)
else
fabricate
(
@
node
,
@node
.
default
)
fabricate
(
@
entry
,
@entry
.
default
)
end
end
def
fabricate
(
node
,
value
=
nil
)
node
.
new
(
value
,
@metadata
).
tap
do
|
entry
|
entry
.
key
=
@attributes
[
:key
]
entry
.
parent
=
@attributes
[
:parent
]
entry
.
description
=
@attributes
[
:description
]
def
fabricate
(
entry
,
value
=
nil
)
entry
.
new
(
value
,
@metadata
).
tap
do
|
node
|
node
.
key
=
@attributes
[
:key
]
node
.
parent
=
@attributes
[
:parent
]
node
.
description
=
@attributes
[
:description
]
end
end
end
...
...
lib/gitlab/ci/config/
node
/global.rb
→
lib/gitlab/ci/config/
entry
/global.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# This class represents a global entry - root
node
for entire
# This class represents a global entry - root
Entry
for entire
# GitLab CI Configuration file.
#
class
Global
<
Entry
class
Global
<
Node
include
Configurable
node
:before_script
,
Node
::
Script
,
node
:before_script
,
Entry
::
Script
,
description:
'Script that will be executed before each job.'
node
:image
,
Node
::
Image
,
node
:image
,
Entry
::
Image
,
description:
'Docker image that will be used to execute jobs.'
node
:services
,
Node
::
Services
,
node
:services
,
Entry
::
Services
,
description:
'Docker images that will be linked to the container.'
node
:after_script
,
Node
::
Script
,
node
:after_script
,
Entry
::
Script
,
description:
'Script that will be executed after each job.'
node
:variables
,
Node
::
Variables
,
node
:variables
,
Entry
::
Variables
,
description:
'Environment variables that will be used.'
node
:stages
,
Node
::
Stages
,
node
:stages
,
Entry
::
Stages
,
description:
'Configuration of stages for this pipeline.'
node
:types
,
Node
::
Stages
,
node
:types
,
Entry
::
Stages
,
description:
'Deprecated: stages for this pipeline.'
node
:cache
,
Node
::
Cache
,
node
:cache
,
Entry
::
Cache
,
description:
'Configure caching between build jobs.'
helpers
:before_script
,
:image
,
:services
,
:after_script
,
...
...
@@ -46,7 +46,7 @@ module Gitlab
private
def
compose_jobs!
factory
=
Node
::
Factory
.
new
(
Node
::
Jobs
)
factory
=
Entry
::
Factory
.
new
(
Entry
::
Jobs
)
.
value
(
@config
.
except
(
*
self
.
class
.
nodes
.
keys
))
.
with
(
key: :jobs
,
parent:
self
,
description:
'Jobs definition for this pipeline'
)
...
...
lib/gitlab/ci/config/
node
/hidden.rb
→
lib/gitlab/ci/config/
entry
/hidden.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents a hidden CI/CD
job
.
# Entry that represents a hidden CI/CD
key
.
#
class
Hidden
<
Entry
class
Hidden
<
Node
include
Validatable
validations
do
...
...
lib/gitlab/ci/config/
node
/image.rb
→
lib/gitlab/ci/config/
entry
/image.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents a Docker image.
#
class
Image
<
Entry
class
Image
<
Node
include
Validatable
validations
do
...
...
lib/gitlab/ci/config/
node
/job.rb
→
lib/gitlab/ci/config/
entry
/job.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents a concrete CI/CD job.
#
class
Job
<
Entry
class
Job
<
Node
include
Configurable
include
Attributable
...
...
@@ -34,43 +34,43 @@ module Gitlab
end
end
node
:before_script
,
Node
::
Script
,
node
:before_script
,
Entry
::
Script
,
description:
'Global before script overridden in this job.'
node
:script
,
Node
::
Commands
,
node
:script
,
Entry
::
Commands
,
description:
'Commands that will be executed in this job.'
node
:stage
,
Node
::
Stage
,
node
:stage
,
Entry
::
Stage
,
description:
'Pipeline stage this job will be executed into.'
node
:type
,
Node
::
Stage
,
node
:type
,
Entry
::
Stage
,
description:
'Deprecated: stage this job will be executed into.'
node
:after_script
,
Node
::
Script
,
node
:after_script
,
Entry
::
Script
,
description:
'Commands that will be executed when finishing job.'
node
:cache
,
Node
::
Cache
,
node
:cache
,
Entry
::
Cache
,
description:
'Cache definition for this job.'
node
:image
,
Node
::
Image
,
node
:image
,
Entry
::
Image
,
description:
'Image that will be used to execute this job.'
node
:services
,
Node
::
Services
,
node
:services
,
Entry
::
Services
,
description:
'Services that will be used to execute this job.'
node
:only
,
Node
::
Trigger
,
node
:only
,
Entry
::
Trigger
,
description:
'Refs policy this job will be executed for.'
node
:except
,
Node
::
Trigger
,
node
:except
,
Entry
::
Trigger
,
description:
'Refs policy this job will be executed for.'
node
:variables
,
Node
::
Variables
,
node
:variables
,
Entry
::
Variables
,
description:
'Environment variables available for this job.'
node
:artifacts
,
Node
::
Artifacts
,
node
:artifacts
,
Entry
::
Artifacts
,
description:
'Artifacts configuration for this job.'
node
:environment
,
Node
::
Environment
,
node
:environment
,
Entry
::
Environment
,
description:
'Environment configuration for this job.'
helpers
:before_script
,
:script
,
:stage
,
:type
,
:after_script
,
...
...
lib/gitlab/ci/config/
node
/jobs.rb
→
lib/gitlab/ci/config/
entry
/jobs.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents a set of jobs.
#
class
Jobs
<
Entry
class
Jobs
<
Node
include
Validatable
validations
do
...
...
@@ -29,9 +29,9 @@ module Gitlab
def
compose!
(
deps
=
nil
)
super
do
@config
.
each
do
|
name
,
config
|
node
=
hidden?
(
name
)
?
Node
::
Hidden
:
Node
::
Job
node
=
hidden?
(
name
)
?
Entry
::
Hidden
:
Entry
::
Job
factory
=
Node
::
Factory
.
new
(
node
)
factory
=
Entry
::
Factory
.
new
(
node
)
.
value
(
config
||
{})
.
metadata
(
name:
name
)
.
with
(
key:
name
,
parent:
self
,
...
...
lib/gitlab/ci/config/
node
/key.rb
→
lib/gitlab/ci/config/
entry
/key.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents a key.
#
class
Key
<
Entry
class
Key
<
Node
include
Validatable
validations
do
...
...
lib/gitlab/ci/config/
node
/legacy_validation_helpers.rb
→
lib/gitlab/ci/config/
entry
/legacy_validation_helpers.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
module
LegacyValidationHelpers
private
...
...
lib/gitlab/ci/config/
node/entry
.rb
→
lib/gitlab/ci/config/
entry/node
.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Base abstract class for each configuration entry node.
#
class
Entry
class
Node
class
InvalidError
<
StandardError
;
end
attr_reader
:config
,
:metadata
...
...
@@ -21,7 +21,7 @@ module Gitlab
end
def
[]
(
key
)
@entries
[
key
]
||
Node
::
Undefined
.
new
@entries
[
key
]
||
Entry
::
Undefined
.
new
end
def
compose!
(
deps
=
nil
)
...
...
lib/gitlab/ci/config/
node
/paths.rb
→
lib/gitlab/ci/config/
entry
/paths.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents an array of paths.
#
class
Paths
<
Entry
class
Paths
<
Node
include
Validatable
validations
do
...
...
lib/gitlab/ci/config/
node
/script.rb
→
lib/gitlab/ci/config/
entry
/script.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents a script.
#
class
Script
<
Entry
class
Script
<
Node
include
Validatable
validations
do
...
...
lib/gitlab/ci/config/
node
/services.rb
→
lib/gitlab/ci/config/
entry
/services.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents a configuration of Docker services.
#
class
Services
<
Entry
class
Services
<
Node
include
Validatable
validations
do
...
...
lib/gitlab/ci/config/
node
/stage.rb
→
lib/gitlab/ci/config/
entry
/stage.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents a stage for a job.
#
class
Stage
<
Entry
class
Stage
<
Node
include
Validatable
validations
do
...
...
lib/gitlab/ci/config/
node
/stages.rb
→
lib/gitlab/ci/config/
entry
/stages.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents a configuration for pipeline stages.
#
class
Stages
<
Entry
class
Stages
<
Node
include
Validatable
validations
do
...
...
lib/gitlab/ci/config/
node
/trigger.rb
→
lib/gitlab/ci/config/
entry
/trigger.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents a trigger policy for the job.
#
class
Trigger
<
Entry
class
Trigger
<
Node
include
Validatable
validations
do
...
...
lib/gitlab/ci/config/
node
/undefined.rb
→
lib/gitlab/ci/config/
entry
/undefined.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# This class represents an undefined
node
.
# This class represents an undefined
entry
.
#
# Implements the Null Object pattern.
#
class
Undefined
<
Entry
class
Undefined
<
Node
def
initialize
(
*
)
super
(
nil
)
end
...
...
lib/gitlab/ci/config/
node
/unspecified.rb
→
lib/gitlab/ci/config/
entry
/unspecified.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# This class represents an unspecified entry
node
.
# This class represents an unspecified entry.
#
# It decorates original entry adding method that indicates it is
# unspecified.
...
...
lib/gitlab/ci/config/
node
/validatable.rb
→
lib/gitlab/ci/config/
entry
/validatable.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
module
Validatable
extend
ActiveSupport
::
Concern
class_methods
do
def
validator
@validator
||=
Class
.
new
(
Node
::
Validator
).
tap
do
|
validator
|
@validator
||=
Class
.
new
(
Entry
::
Validator
).
tap
do
|
validator
|
if
defined?
(
@validations
)
@validations
.
each
{
|
rules
|
validator
.
class_eval
(
&
rules
)
}
end
...
...
lib/gitlab/ci/config/
node
/validator.rb
→
lib/gitlab/ci/config/
entry
/validator.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
class
Validator
<
SimpleDelegator
include
ActiveModel
::
Validations
include
Node
::
Validators
include
Entry
::
Validators
def
initialize
(
node
)
super
(
node
)
@
node
=
node
def
initialize
(
entry
)
super
(
entry
)
@
entry
=
entry
end
def
messages
...
...
@@ -30,7 +30,7 @@ module Gitlab
def
key_name
if
key
.
blank?
@
node
.
class
.
name
.
demodulize
.
underscore
.
humanize
@
entry
.
class
.
name
.
demodulize
.
underscore
.
humanize
else
key
end
...
...
lib/gitlab/ci/config/
node
/validators.rb
→
lib/gitlab/ci/config/
entry
/validators.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
module
Validators
class
AllowedKeysValidator
<
ActiveModel
::
EachValidator
def
validate_each
(
record
,
attribute
,
value
)
...
...
lib/gitlab/ci/config/
node
/variables.rb
→
lib/gitlab/ci/config/
entry
/variables.rb
View file @
c7014683
module
Gitlab
module
Ci
class
Config
module
Node
module
Entry
##
# Entry that represents environment variables.
#
class
Variables
<
Entry
class
Variables
<
Node
include
Validatable
validations
do
...
...
spec/lib/gitlab/ci/config/
node
/artifacts_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/artifacts_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Artifacts
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Artifacts
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validation'
do
...
...
spec/lib/gitlab/ci/config/
node
/attributable_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/attributable_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Attributable
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Attributable
do
let
(
:node
)
{
Class
.
new
}
let
(
:instance
)
{
node
.
new
}
...
...
spec/lib/gitlab/ci/config/
node
/boolean_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/boolean_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Boolean
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Boolean
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
...
...
spec/lib/gitlab/ci/config/
node
/cache_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/cache_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Cache
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Cache
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
...
...
spec/lib/gitlab/ci/config/
node
/commands_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/commands_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Commands
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Commands
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
context
'when entry config value is an array'
do
...
...
spec/lib/gitlab/ci/config/
node
/configurable_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/configurable_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Configurable
do
let
(
:
node
)
{
Class
.
new
}
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Configurable
do
let
(
:
entry
)
{
Class
.
new
}
before
do
node
.
include
(
described_class
)
entry
.
include
(
described_class
)
end
describe
'validations'
do
let
(
:validator
)
{
node
.
validator
.
new
(
instance
)
}
let
(
:validator
)
{
entry
.
validator
.
new
(
instance
)
}
before
do
node
.
class_eval
do
entry
.
class_eval
do
attr_reader
:config
def
initialize
(
config
)
...
...
@@ -22,16 +22,16 @@ describe Gitlab::Ci::Config::Node::Configurable do
validator
.
validate
end
context
'when
node
validator is invalid'
do
let
(
:instance
)
{
node
.
new
(
'ls'
)
}
context
'when
entry
validator is invalid'
do
let
(
:instance
)
{
entry
.
new
(
'ls'
)
}
it
'returns invalid validator'
do
expect
(
validator
).
to
be_invalid
end
end
context
'when
node
instance is valid'
do
let
(
:instance
)
{
node
.
new
(
key:
'value'
)
}
context
'when
entry
instance is valid'
do
let
(
:instance
)
{
entry
.
new
(
key:
'value'
)
}
it
'returns valid validator'
do
expect
(
validator
).
to
be_valid
...
...
@@ -41,24 +41,24 @@ describe Gitlab::Ci::Config::Node::Configurable do
describe
'configured nodes'
do
before
do
node
.
class_eval
do
entry
.
class_eval
do
node
:object
,
Object
,
description:
'test object'
end
end
describe
'.nodes'
do
it
'has valid nodes'
do
expect
(
node
.
nodes
).
to
include
:object
expect
(
entry
.
nodes
).
to
include
:object
end
it
'creates a node factory'
do
expect
(
node
.
nodes
[
:object
])
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Factory
expect
(
entry
.
nodes
[
:object
])
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Entry
::
Factory
end
it
'returns a duplicated factory object'
do
first_factory
=
node
.
nodes
[
:object
]
second_factory
=
node
.
nodes
[
:object
]
first_factory
=
entry
.
nodes
[
:object
]
second_factory
=
entry
.
nodes
[
:object
]
expect
(
first_factory
).
not_to
be_equal
(
second_factory
)
end
...
...
spec/lib/gitlab/ci/config/
node
/environment_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/environment_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Environment
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Environment
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
before
{
entry
.
compose!
}
...
...
spec/lib/gitlab/ci/config/
node
/factory_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/factory_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Factory
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Factory
do
describe
'#create!'
do
let
(
:factory
)
{
described_class
.
new
(
node
)
}
let
(
:
node
)
{
Gitlab
::
Ci
::
Config
::
Node
::
Script
}
let
(
:factory
)
{
described_class
.
new
(
entry
)
}
let
(
:
entry
)
{
Gitlab
::
Ci
::
Config
::
Entry
::
Script
}
context
'when setting a concrete value'
do
it
'creates entry with valid value'
do
...
...
@@ -54,7 +54,7 @@ describe Gitlab::Ci::Config::Node::Factory do
context
'when not setting a value'
do
it
'raises error'
do
expect
{
factory
.
create!
}.
to
raise_error
(
Gitlab
::
Ci
::
Config
::
Node
::
Factory
::
InvalidFactory
Gitlab
::
Ci
::
Config
::
Entry
::
Factory
::
InvalidFactory
)
end
end
...
...
@@ -66,12 +66,12 @@ describe Gitlab::Ci::Config::Node::Factory do
.
create!
expect
(
entry
)
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Unspecified
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Entry
::
Unspecified
end
end
context
'when passing metadata'
do
let
(
:
node
)
{
spy
(
'node
'
)
}
let
(
:
entry
)
{
spy
(
'entry
'
)
}
it
'passes metadata as a parameter'
do
factory
...
...
@@ -79,7 +79,7 @@ describe Gitlab::Ci::Config::Node::Factory do
.
metadata
(
some:
'hash'
)
.
create!
expect
(
node
).
to
have_received
(
:new
)
expect
(
entry
).
to
have_received
(
:new
)
.
with
(
'some value'
,
{
some:
'hash'
})
end
end
...
...
spec/lib/gitlab/ci/config/
node
/global_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/global_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Global
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Global
do
let
(
:global
)
{
described_class
.
new
(
hash
)
}
describe
'.nodes'
do
...
...
@@ -40,9 +40,9 @@ describe Gitlab::Ci::Config::Node::Global do
it
'creates node object using valid class'
do
expect
(
global
.
descendants
.
first
)
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Script
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Entry
::
Script
expect
(
global
.
descendants
.
second
)
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Image
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Entry
::
Image
end
it
'sets correct description for nodes'
do
...
...
@@ -181,7 +181,7 @@ describe Gitlab::Ci::Config::Node::Global do
it
'contains unspecified nodes'
do
expect
(
global
.
descendants
.
first
)
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Unspecified
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Entry
::
Unspecified
end
end
...
...
@@ -284,7 +284,7 @@ describe Gitlab::Ci::Config::Node::Global do
context
'when node exists'
do
it
'returns correct entry'
do
expect
(
global
[
:cache
])
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Cache
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Entry
::
Cache
expect
(
global
[
:jobs
][
:rspec
][
:script
].
value
).
to
eq
[
'ls'
]
end
end
...
...
spec/lib/gitlab/ci/config/
node
/hidden_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/hidden_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Hidden
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Hidden
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
...
...
spec/lib/gitlab/ci/config/
node
/image_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/image_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Image
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Image
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validation'
do
...
...
spec/lib/gitlab/ci/config/
node
/job_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/job_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Job
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Job
do
let
(
:entry
)
{
described_class
.
new
(
config
,
name: :rspec
)
}
describe
'validations'
do
...
...
spec/lib/gitlab/ci/config/
node
/jobs_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/jobs_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Jobs
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Jobs
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
...
...
@@ -74,9 +74,9 @@ describe Gitlab::Ci::Config::Node::Jobs do
it
'creates valid descendant nodes'
do
expect
(
entry
.
descendants
.
count
).
to
eq
3
expect
(
entry
.
descendants
.
first
(
2
))
.
to
all
(
be_an_instance_of
(
Gitlab
::
Ci
::
Config
::
Node
::
Job
))
.
to
all
(
be_an_instance_of
(
Gitlab
::
Ci
::
Config
::
Entry
::
Job
))
expect
(
entry
.
descendants
.
last
)
.
to
be_an_instance_of
(
Gitlab
::
Ci
::
Config
::
Node
::
Hidden
)
.
to
be_an_instance_of
(
Gitlab
::
Ci
::
Config
::
Entry
::
Hidden
)
end
end
...
...
spec/lib/gitlab/ci/config/
node
/key_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/key_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Key
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Key
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
...
...
spec/lib/gitlab/ci/config/
node
/paths_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/paths_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Paths
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Paths
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
...
...
spec/lib/gitlab/ci/config/
node
/script_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/script_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Script
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Script
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
...
...
spec/lib/gitlab/ci/config/
node
/services_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/services_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Services
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Services
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
...
...
spec/lib/gitlab/ci/config/
node
/stage_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/stage_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Stage
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Stage
do
let
(
:stage
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
...
...
spec/lib/gitlab/ci/config/
node
/stages_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/stages_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Stages
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Stages
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
...
...
spec/lib/gitlab/ci/config/
node
/trigger_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/trigger_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Trigger
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Trigger
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
...
...
spec/lib/gitlab/ci/config/
node
/undefined_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/undefined_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Undefined
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Undefined
do
let
(
:entry
)
{
described_class
.
new
}
describe
'#leaf?'
do
...
...
spec/lib/gitlab/ci/config/
node
/unspecified_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/unspecified_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Unspecified
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Unspecified
do
let
(
:unspecified
)
{
described_class
.
new
(
entry
)
}
let
(
:entry
)
{
spy
(
'Entry'
)
}
...
...
spec/lib/gitlab/ci/config/
node
/validatable_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/validatable_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Validatable
do
let
(
:
node
)
{
Class
.
new
}
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Validatable
do
let
(
:
entry
)
{
Class
.
new
}
before
do
node
.
include
(
described_class
)
entry
.
include
(
described_class
)
end
describe
'.validator'
do
before
do
node
.
class_eval
do
entry
.
class_eval
do
attr_accessor
:test_attribute
validations
do
...
...
@@ -19,34 +19,34 @@ describe Gitlab::Ci::Config::Node::Validatable do
end
it
'returns validator'
do
expect
(
node
.
validator
.
superclass
)
.
to
be
Gitlab
::
Ci
::
Config
::
Node
::
Validator
expect
(
entry
.
validator
.
superclass
)
.
to
be
Gitlab
::
Ci
::
Config
::
Entry
::
Validator
end
it
'returns only one validator to mitigate leaks'
do
expect
{
node
.
validator
}.
not_to
change
{
node
.
validator
}
expect
{
entry
.
validator
}.
not_to
change
{
entry
.
validator
}
end
context
'when validating
node
instance'
do
let
(
:
node_instance
)
{
node
.
new
}
context
'when validating
entry
instance'
do
let
(
:
entry_instance
)
{
entry
.
new
}
context
'when attribute is valid'
do
before
do
node
_instance
.
test_attribute
=
'valid'
entry
_instance
.
test_attribute
=
'valid'
end
it
'instance of validator is valid'
do
expect
(
node
.
validator
.
new
(
node
_instance
)).
to
be_valid
expect
(
entry
.
validator
.
new
(
entry
_instance
)).
to
be_valid
end
end
context
'when attribute is not valid'
do
before
do
node
_instance
.
test_attribute
=
nil
entry
_instance
.
test_attribute
=
nil
end
it
'instance of validator is invalid'
do
expect
(
node
.
validator
.
new
(
node
_instance
)).
to
be_invalid
expect
(
entry
.
validator
.
new
(
entry
_instance
)).
to
be_invalid
end
end
end
...
...
spec/lib/gitlab/ci/config/
node
/validator_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/validator_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Validator
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Validator
do
let
(
:validator
)
{
Class
.
new
(
described_class
)
}
let
(
:validator_instance
)
{
validator
.
new
(
node
)
}
let
(
:node
)
{
spy
(
'node'
)
}
...
...
spec/lib/gitlab/ci/config/
node
/variables_spec.rb
→
spec/lib/gitlab/ci/config/
entry
/variables_spec.rb
View file @
c7014683
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Variables
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Variables
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
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