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
Tatuya Kamada
gitlab-ce
Commits
c019585c
Commit
c019585c
authored
Jun 27, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate interface only with CI node validator
parent
56e88b8c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
40 deletions
+24
-40
lib/gitlab/ci/config/node/cache.rb
lib/gitlab/ci/config/node/cache.rb
+16
-13
lib/gitlab/ci/config/node/validator.rb
lib/gitlab/ci/config/node/validator.rb
+1
-2
spec/lib/gitlab/ci/config/node/validator_spec.rb
spec/lib/gitlab/ci/config/node/validator_spec.rb
+7
-25
No files found.
lib/gitlab/ci/config/node/cache.rb
View file @
c019585c
...
@@ -8,30 +8,33 @@ module Gitlab
...
@@ -8,30 +8,33 @@ module Gitlab
class
Cache
<
Entry
class
Cache
<
Entry
include
Configurable
include
Configurable
node
:key
,
Key
,
description:
'Cache key used to define a cache affinity.'
node
:untracked
,
Boolean
,
description:
'Cache all untracked files.'
node
:paths
,
Paths
,
description:
'Specify which paths should be cached across builds.'
validations
do
validations
do
validate
:
allowed_
keys
validate
:keys
def
unknown_keys
def
unknown_keys
return
[]
unless
@node
.
config
.
is_a?
(
Hash
)
return
[]
unless
config
.
is_a?
(
Hash
)
config
.
keys
-
allowed_keys
@node
.
config
.
keys
-
@node
.
class
.
nodes
.
keys
end
end
def
allowed_
keys
def
keys
if
unknown_keys
.
any?
if
unknown_keys
.
any?
errors
.
add
(
:config
,
"contains unknown keys
#{
unknown_keys
}
"
)
errors
.
add
(
:config
,
"contains unknown keys
#{
unknown_keys
}
"
)
end
end
end
end
end
end
node
:key
,
Node
::
Key
,
def
allowed_keys
description:
'Cache key used to define a cache affinity.'
self
.
class
.
nodes
.
keys
end
node
:untracked
,
Boolean
,
description:
'Cache all untracked files.'
node
:paths
,
Paths
,
description:
'Specify which paths should be cached across builds.'
end
end
end
end
end
end
...
...
lib/gitlab/ci/config/node/validator.rb
View file @
c019585c
...
@@ -8,12 +8,11 @@ module Gitlab
...
@@ -8,12 +8,11 @@ module Gitlab
def
initialize
(
node
)
def
initialize
(
node
)
super
(
node
)
super
(
node
)
@node
=
node
end
end
def
messages
def
messages
errors
.
full_messages
.
map
do
|
error
|
errors
.
full_messages
.
map
do
|
error
|
"
#{
@node
.
key
}
#{
error
}
"
.
humanize
"
#{
key
}
#{
error
}
"
.
humanize
end
end
end
end
...
...
spec/lib/gitlab/ci/config/node/validator_spec.rb
View file @
c019585c
...
@@ -5,7 +5,13 @@ describe Gitlab::Ci::Config::Node::Validator do
...
@@ -5,7 +5,13 @@ describe Gitlab::Ci::Config::Node::Validator do
let
(
:validator_instance
)
{
validator
.
new
(
node
)
}
let
(
:validator_instance
)
{
validator
.
new
(
node
)
}
let
(
:node
)
{
spy
(
'node'
)
}
let
(
:node
)
{
spy
(
'node'
)
}
shared_examples
'delegated validator'
do
describe
'delegated validator'
do
before
do
validator
.
class_eval
do
validates
:test_attribute
,
presence:
true
end
end
context
'when node is valid'
do
context
'when node is valid'
do
before
do
before
do
allow
(
node
).
to
receive
(
:test_attribute
).
and_return
(
'valid value'
)
allow
(
node
).
to
receive
(
:test_attribute
).
and_return
(
'valid value'
)
...
@@ -40,28 +46,4 @@ describe Gitlab::Ci::Config::Node::Validator do
...
@@ -40,28 +46,4 @@ describe Gitlab::Ci::Config::Node::Validator do
end
end
end
end
end
end
describe
'attributes validations'
do
before
do
validator
.
class_eval
do
validates
:test_attribute
,
presence:
true
end
end
it_behaves_like
'delegated validator'
end
describe
'interface validations'
do
before
do
validator
.
class_eval
do
validate
do
unless
@node
.
test_attribute
==
'valid value'
errors
.
add
(
:test_attribute
,
'invalid value'
)
end
end
end
end
it_behaves_like
'delegated validator'
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