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
57451f52
Commit
57451f52
authored
Aug 09, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Memoize CI config node validator to prevent leaks
parent
551ffc0a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
lib/gitlab/ci/config/node/validatable.rb
lib/gitlab/ci/config/node/validatable.rb
+4
-6
spec/lib/gitlab/ci/config/node/validatable_spec.rb
spec/lib/gitlab/ci/config/node/validatable_spec.rb
+4
-0
No files found.
lib/gitlab/ci/config/node/validatable.rb
View file @
57451f52
...
...
@@ -7,13 +7,11 @@ module Gitlab
class_methods
do
def
validator
validator
=
Class
.
new
(
Node
::
Validator
)
if
defined?
(
@validations
)
@validations
.
each
{
|
rules
|
validator
.
class_eval
(
&
rules
)
}
@validator
||=
Class
.
new
(
Node
::
Validator
).
tap
do
|
validator
|
if
defined?
(
@validations
)
@validations
.
each
{
|
rules
|
validator
.
class_eval
(
&
rules
)
}
end
end
validator
end
private
...
...
spec/lib/gitlab/ci/config/node/validatable_spec.rb
View file @
57451f52
...
...
@@ -23,6 +23,10 @@ describe Gitlab::Ci::Config::Node::Validatable do
.
to
be
Gitlab
::
Ci
::
Config
::
Node
::
Validator
end
it
'returns only one validator to mitigate leaks'
do
expect
{
node
.
validator
}.
not_to
change
{
node
.
validator
}
end
context
'when validating node instance'
do
let
(
:node_instance
)
{
node
.
new
}
...
...
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