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
ecdcf04e
Commit
ecdcf04e
authored
Jul 07, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add undefined CI node strategies to handle defaults
parent
de8b93bb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
14 deletions
+33
-14
undefined.rb
lib/gitlab/ci/config/node/undefined.rb
+33
-14
No files found.
lib/gitlab/ci/config/node/undefined.rb
View file @
ecdcf04e
...
@@ -13,38 +13,57 @@ module Gitlab
...
@@ -13,38 +13,57 @@ module Gitlab
class
Undefined
<
Entry
class
Undefined
<
Entry
include
Validatable
include
Validatable
delegate
:valid?
,
:errors
,
:value
,
to: :@strategy
validations
do
validations
do
validates
:config
,
type:
Class
validates
:config
,
type:
Class
end
end
def
initialize
(
node
)
def
initialize
(
node
)
super
super
@strategy
=
create_strategy
(
node
,
node
.
default
)
unless
node
.
default
.
nil?
@default
=
fabricate_default
(
node
)
end
end
def
defined?
false
end
end
def
value
private
@default
.
value
if
@default
def
create_strategy
(
node
,
default
)
if
default
.
nil?
Undefined
::
NullStrategy
.
new
else
entry
=
Node
::
Factory
.
fabricate
(
node
,
default
,
attributes
)
Undefined
::
DefaultStrategy
.
new
(
entry
)
end
end
end
def
valid?
class
DefaultStrategy
@default
?
@default
.
valid?
:
true
delegate
:valid?
,
:errors
,
:value
,
to: :@default
def
initialize
(
entry
)
@default
=
entry
end
end
end
def
errors
class
NullStrategy
@default
?
@default
.
errors
:
[]
def
initialize
(
*
)
end
end
def
defined?
def
value
false
nil
end
end
private
def
valid?
true
end
def
fabricate_default
(
node
)
def
errors
Node
::
Factory
.
fabricate
(
node
,
node
.
default
,
attributes
)
[]
end
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