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
ac440507
Commit
ac440507
authored
Jan 21, 2021
by
alinamihaila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add skip_validation attribute to metric definition
Use each instead of map
parent
5ebfde5b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
config/metrics/schema.json
config/metrics/schema.json
+3
-0
lib/gitlab/usage/metric_definition.rb
lib/gitlab/usage/metric_definition.rb
+10
-2
spec/lib/gitlab/usage/metric_definition_spec.rb
spec/lib/gitlab/usage/metric_definition_spec.rb
+6
-0
No files found.
config/metrics/schema.json
View file @
ac440507
...
...
@@ -55,6 +55,9 @@
"type"
:
"string"
,
"enum"
:
[
"free"
,
"starter"
,
"premium"
,
"ultimate"
,
"bronze"
,
"silver"
,
"gold"
]
}
},
"skip_validation"
:
{
"type"
:
"boolean"
}
}
}
lib/gitlab/usage/metric_definition.rb
View file @
ac440507
...
...
@@ -22,8 +22,10 @@ module Gitlab
end
def
validate!
self
.
class
.
schemer
.
validate
(
attributes
.
stringify_keys
).
map
do
|
error
|
Gitlab
::
ErrorTracking
.
track_and_raise_for_dev_exception
(
Metric
::
InvalidMetricError
.
new
(
"
#{
error
[
"details"
]
||
error
[
'data_pointer'
]
}
for `
#{
path
}
`"
))
unless
skip_validation?
self
.
class
.
schemer
.
validate
(
attributes
.
stringify_keys
).
each
do
|
error
|
Gitlab
::
ErrorTracking
.
track_and_raise_for_dev_exception
(
Metric
::
InvalidMetricError
.
new
(
"
#{
error
[
"details"
]
||
error
[
'data_pointer'
]
}
for `
#{
path
}
`"
))
end
end
end
...
...
@@ -78,6 +80,12 @@ module Gitlab
def
method_missing
(
method
,
*
args
)
attributes
[
method
]
||
super
end
def
skip_validation?
return
false
if
attributes
[
:skip_validation
].
blank?
attributes
[
:skip_validation
]
end
end
end
end
...
...
spec/lib/gitlab/usage/metric_definition_spec.rb
View file @
ac440507
...
...
@@ -65,6 +65,12 @@ RSpec.describe Gitlab::Usage::MetricDefinition do
described_class
.
new
(
path
,
attributes
).
validate!
end
it
'does not raise exception if has skip_validation: true'
do
expect
(
Gitlab
::
ErrorTracking
).
not_to
receive
(
:track_and_raise_for_dev_exception
)
described_class
.
new
(
path
,
attributes
.
merge
(
{
skip_validation:
true
}
)).
validate!
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