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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e84230eb
Commit
e84230eb
authored
Oct 04, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add limitation for start_in keyword
parent
28f895e4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
5 deletions
+27
-5
lib/gitlab/ci/config/entry/job.rb
lib/gitlab/ci/config/entry/job.rb
+1
-1
lib/gitlab/ci/config/entry/legacy_validation_helpers.rb
lib/gitlab/ci/config/entry/legacy_validation_helpers.rb
+9
-0
lib/gitlab/ci/config/entry/validators.rb
lib/gitlab/ci/config/entry/validators.rb
+6
-0
spec/lib/gitlab/ci/config/entry/job_spec.rb
spec/lib/gitlab/ci/config/entry/job_spec.rb
+11
-4
No files found.
lib/gitlab/ci/config/entry/job.rb
View file @
e84230eb
...
...
@@ -36,7 +36,7 @@ module Gitlab
validates
:extends
,
type:
String
end
validates
:start_in
,
duration:
true
,
if: :delayed?
validates
:start_in
,
duration:
{
limit:
'1 day'
}
,
if: :delayed?
validates
:start_in
,
absence:
true
,
unless: :delayed?
end
...
...
lib/gitlab/ci/config/entry/legacy_validation_helpers.rb
View file @
e84230eb
...
...
@@ -11,6 +11,15 @@ module Gitlab
false
end
def
validate_duration_limit
(
value
,
limit
)
return
false
unless
value
.
is_a?
(
String
)
ChronicDuration
.
parse
(
value
).
second
.
from_now
<
ChronicDuration
.
parse
(
limit
).
second
.
from_now
rescue
ChronicDuration
::
DurationParseError
false
end
def
validate_array_of_strings
(
values
)
values
.
is_a?
(
Array
)
&&
values
.
all?
{
|
value
|
validate_string
(
value
)
}
end
...
...
lib/gitlab/ci/config/entry/validators.rb
View file @
e84230eb
...
...
@@ -49,6 +49,12 @@ module Gitlab
unless
validate_duration
(
value
)
record
.
errors
.
add
(
attribute
,
'should be a duration'
)
end
if
options
[
:limit
]
unless
validate_duration_limit
(
value
,
options
[
:limit
])
record
.
errors
.
add
(
attribute
,
'should not exceed the limit'
)
end
end
end
end
...
...
spec/lib/gitlab/ci/config/entry/job_spec.rb
View file @
e84230eb
...
...
@@ -44,9 +44,7 @@ describe Gitlab::Ci::Config::Entry::Job do
context
'when start_in is specified'
do
let
(
:config
)
{
{
script:
'echo'
,
when:
'delayed'
,
start_in:
'1 day'
}
}
it
'returns error about invalid type'
do
expect
(
entry
).
to
be_valid
end
it
{
expect
(
entry
).
to
be_valid
}
end
end
end
...
...
@@ -158,7 +156,7 @@ describe Gitlab::Ci::Config::Entry::Job do
end
end
context
'when start_in is not format
eed ad
a duration'
do
context
'when start_in is not format
ted as
a duration'
do
let
(
:config
)
{
{
when:
'delayed'
,
start_in:
'test'
}
}
it
'returns error about invalid type'
do
...
...
@@ -166,6 +164,15 @@ describe Gitlab::Ci::Config::Entry::Job do
expect
(
entry
.
errors
).
to
include
'job start in should be a duration'
end
end
context
'when start_in is longer than one day'
do
let
(
:config
)
{
{
when:
'delayed'
,
start_in:
'2 days'
}
}
it
'returns error about exceeding the limit'
do
expect
(
entry
).
not_to
be_valid
expect
(
entry
.
errors
).
to
include
'job start in should not exceed the limit'
end
end
end
context
'when start_in specified without delayed specification'
do
...
...
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