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
c8c930f3
Commit
c8c930f3
authored
Jun 29, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CI config entry validator for allowed keys
parent
b85d4969
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
18 deletions
+17
-18
lib/gitlab/ci/config/node/cache.rb
lib/gitlab/ci/config/node/cache.rb
+1
-17
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+1
-1
lib/gitlab/ci/config/node/validator.rb
lib/gitlab/ci/config/node/validator.rb
+5
-0
lib/gitlab/ci/config/node/validators.rb
lib/gitlab/ci/config/node/validators.rb
+10
-0
No files found.
lib/gitlab/ci/config/node/cache.rb
View file @
c8c930f3
...
...
@@ -18,23 +18,7 @@ module Gitlab
description:
'Specify which paths should be cached across builds.'
validations
do
validate
:keys
def
unknown_keys
return
[]
unless
config
.
is_a?
(
Hash
)
config
.
keys
-
allowed_keys
end
def
keys
if
unknown_keys
.
any?
unknown_list
=
unknown_keys
.
join
(
', '
)
errors
.
add
(
:config
,
"contains unknown keys:
#{
unknown_list
}
"
)
end
end
end
def
allowed_keys
self
.
class
.
nodes
.
keys
validates
:config
,
allowed_keys:
true
end
end
end
...
...
lib/gitlab/ci/config/node/entry.rb
View file @
c8c930f3
...
...
@@ -51,7 +51,7 @@ module Gitlab
@config
else
defined
=
@nodes
.
select
{
|
_key
,
value
|
value
.
defined?
}
Hash
[
(
defined
)
.
map
{
|
key
,
node
|
[
key
,
node
.
value
]
}]
Hash
[
defined
.
map
{
|
key
,
node
|
[
key
,
node
.
value
]
}]
end
end
...
...
lib/gitlab/ci/config/node/validator.rb
View file @
c8c930f3
...
...
@@ -21,6 +21,11 @@ module Gitlab
'Validator'
end
def
unknown_keys
return
[]
unless
config
.
is_a?
(
Hash
)
config
.
keys
-
@node
.
class
.
nodes
.
keys
end
private
def
location
...
...
lib/gitlab/ci/config/node/validators.rb
View file @
c8c930f3
...
...
@@ -3,6 +3,16 @@ module Gitlab
class
Config
module
Node
module
Validators
class
AllowedKeysValidator
<
ActiveModel
::
EachValidator
def
validate_each
(
record
,
attribute
,
value
)
if
record
.
unknown_keys
.
any?
unknown_list
=
record
.
unknown_keys
.
join
(
', '
)
record
.
errors
.
add
(
:config
,
"contains unknown keys:
#{
unknown_list
}
"
)
end
end
end
class
ArrayOfStringsValidator
<
ActiveModel
::
EachValidator
include
LegacyValidationHelpers
...
...
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