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
251dd571
Commit
251dd571
authored
Jun 06, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract CI config validation helpers to mixin
parent
8048dcc8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
16 deletions
+28
-16
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+2
-16
lib/gitlab/ci/config/validation_helpers.rb
lib/gitlab/ci/config/validation_helpers.rb
+26
-0
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
251dd571
...
...
@@ -2,6 +2,8 @@ module Ci
class
GitlabCiYamlProcessor
class
ValidationError
<
StandardError
;
end
include
Gitlab
::
Ci
::
Config
::
ValidationHelpers
DEFAULT_STAGES
=
%w(build test deploy)
DEFAULT_STAGE
=
'test'
ALLOWED_YAML_KEYS
=
[
:before_script
,
:after_script
,
:image
,
:services
,
:types
,
:stages
,
:variables
,
:cache
]
...
...
@@ -276,22 +278,6 @@ module Ci
end
end
def
validate_array_of_strings
(
values
)
values
.
is_a?
(
Array
)
&&
values
.
all?
{
|
value
|
validate_string
(
value
)
}
end
def
validate_variables
(
variables
)
variables
.
is_a?
(
Hash
)
&&
variables
.
all?
{
|
key
,
value
|
validate_string
(
key
)
&&
validate_string
(
value
)
}
end
def
validate_string
(
value
)
value
.
is_a?
(
String
)
||
value
.
is_a?
(
Symbol
)
end
def
validate_boolean
(
value
)
value
.
in?
([
true
,
false
])
end
def
process?
(
only_params
,
except_params
,
ref
,
tag
,
trigger_request
)
if
only_params
.
present?
return
false
unless
matching?
(
only_params
,
ref
,
tag
,
trigger_request
)
...
...
lib/gitlab/ci/config/validation_helpers.rb
0 → 100644
View file @
251dd571
module
Gitlab
module
Ci
class
Config
module
ValidationHelpers
private
def
validate_array_of_strings
(
values
)
values
.
is_a?
(
Array
)
&&
values
.
all?
{
|
value
|
validate_string
(
value
)
}
end
def
validate_variables
(
variables
)
variables
.
is_a?
(
Hash
)
&&
variables
.
all?
{
|
key
,
value
|
validate_string
(
key
)
&&
validate_string
(
value
)
}
end
def
validate_string
(
value
)
value
.
is_a?
(
String
)
||
value
.
is_a?
(
Symbol
)
end
def
validate_boolean
(
value
)
value
.
in?
([
true
,
false
])
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