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