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
4d2caa25
Commit
4d2caa25
authored
Aug 07, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update variables and specs
- Update URL helper
parent
786a5a45
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
22 deletions
+20
-22
app/presenters/alert_management/alert_presenter.rb
app/presenters/alert_management/alert_presenter.rb
+3
-4
app/presenters/projects/prometheus/alert_presenter.rb
app/presenters/projects/prometheus/alert_presenter.rb
+4
-5
app/services/incident_management/create_issue_service.rb
app/services/incident_management/create_issue_service.rb
+6
-6
lib/gitlab/alerting/alert.rb
lib/gitlab/alerting/alert.rb
+2
-2
spec/presenters/alert_management/alert_presenter_spec.rb
spec/presenters/alert_management/alert_presenter_spec.rb
+2
-2
spec/presenters/alert_management/prometheus_alert_presenter_spec.rb
...nters/alert_management/prometheus_alert_presenter_spec.rb
+1
-1
spec/presenters/projects/prometheus/alert_presenter_spec.rb
spec/presenters/projects/prometheus/alert_presenter_spec.rb
+2
-2
No files found.
app/presenters/alert_management/alert_presenter.rb
View file @
4d2caa25
...
@@ -48,10 +48,9 @@ module AlertManagement
...
@@ -48,10 +48,9 @@ module AlertManagement
private
private
def
details_url
def
details_url
::
Gitlab
::
Routing
.
url_helpers
.
details_namespace_project_alert_management_url
(
::
Gitlab
::
Routing
.
url_helpers
.
details_project_alert_management_url
(
id:
alert
,
project
,
project_id:
project
,
alert
.
iid
namespace_id:
project
.
namespace
)
)
end
end
...
...
app/presenters/projects/prometheus/alert_presenter.rb
View file @
4d2caa25
...
@@ -78,12 +78,11 @@ module Projects
...
@@ -78,12 +78,11 @@ module Projects
end
end
def
details_url
def
details_url
return
unless
alert
return
unless
a
m_a
lert
::
Gitlab
::
Routing
.
url_helpers
.
details_namespace_project_alert_management_url
(
::
Gitlab
::
Routing
.
url_helpers
.
details_project_alert_management_url
(
id:
alert
,
project
,
project_id:
project
,
am_alert
.
iid
namespace_id:
project
.
namespace
)
)
end
end
...
...
app/services/incident_management/create_issue_service.rb
View file @
4d2caa25
...
@@ -14,7 +14,7 @@ module IncidentManagement
...
@@ -14,7 +14,7 @@ module IncidentManagement
def
execute
def
execute
return
error
(
'setting disabled'
)
unless
incident_management_setting
.
create_issue?
return
error
(
'setting disabled'
)
unless
incident_management_setting
.
create_issue?
return
error
(
'invalid alert'
)
unless
presented_alert
.
valid?
return
error
(
'invalid alert'
)
unless
alert_presenter
.
valid?
result
=
create_incident
result
=
create_incident
return
error
(
result
.
message
,
result
.
payload
[
:issue
])
unless
result
.
success?
return
error
(
result
.
message
,
result
.
payload
[
:issue
])
unless
result
.
success?
...
@@ -34,7 +34,7 @@ module IncidentManagement
...
@@ -34,7 +34,7 @@ module IncidentManagement
end
end
def
issue_title
def
issue_title
presented_alert
.
full_title
alert_presenter
.
full_title
end
end
def
issue_description
def
issue_description
...
@@ -48,15 +48,15 @@ module IncidentManagement
...
@@ -48,15 +48,15 @@ module IncidentManagement
end
end
def
alert_summary
def
alert_summary
presented_alert
.
issue_summary_markdown
alert_presenter
.
issue_summary_markdown
end
end
def
alert_markdown
def
alert_markdown
presented_alert
.
alert_markdown
alert_presenter
.
alert_markdown
end
end
def
presented_alert
def
alert_presenter
strong_memoize
(
:
presented_alert
)
do
strong_memoize
(
:
alert_presenter
)
do
Gitlab
::
Alerting
::
Alert
.
for_alert_management_alert
(
project:
project
,
alert:
alert
).
present
Gitlab
::
Alerting
::
Alert
.
for_alert_management_alert
(
project:
project
,
alert:
alert
).
present
end
end
end
end
...
...
lib/gitlab/alerting/alert.rb
View file @
4d2caa25
...
@@ -7,7 +7,7 @@ module Gitlab
...
@@ -7,7 +7,7 @@ module Gitlab
include
Gitlab
::
Utils
::
StrongMemoize
include
Gitlab
::
Utils
::
StrongMemoize
include
Presentable
include
Presentable
attr_accessor
:project
,
:payload
,
:alert
attr_accessor
:project
,
:payload
,
:a
m_a
lert
def
self
.
for_alert_management_alert
(
project
:,
alert
:)
def
self
.
for_alert_management_alert
(
project
:,
alert
:)
params
=
if
alert
.
prometheus?
params
=
if
alert
.
prometheus?
...
@@ -16,7 +16,7 @@ module Gitlab
...
@@ -16,7 +16,7 @@ module Gitlab
Gitlab
::
Alerting
::
NotificationPayloadParser
.
call
(
alert
.
payload
.
to_h
,
alert
.
project
)
Gitlab
::
Alerting
::
NotificationPayloadParser
.
call
(
alert
.
payload
.
to_h
,
alert
.
project
)
end
end
self
.
new
(
project:
project
,
payload:
params
,
alert:
alert
)
self
.
new
(
project:
project
,
payload:
params
,
a
m_a
lert:
alert
)
end
end
def
gitlab_alert
def
gitlab_alert
...
...
spec/presenters/alert_management/alert_presenter_spec.rb
View file @
4d2caa25
...
@@ -5,7 +5,7 @@ require 'spec_helper'
...
@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec
.
describe
AlertManagement
::
AlertPresenter
do
RSpec
.
describe
AlertManagement
::
AlertPresenter
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let
(
:generic_payload
)
do
let
_it_be
(
:generic_payload
)
do
{
{
'title'
=>
'Alert title'
,
'title'
=>
'Alert title'
,
'start_time'
=>
'2020-04-27T10:10:22.265949279Z'
,
'start_time'
=>
'2020-04-27T10:10:22.265949279Z'
,
...
@@ -18,7 +18,7 @@ RSpec.describe AlertManagement::AlertPresenter do
...
@@ -18,7 +18,7 @@ RSpec.describe AlertManagement::AlertPresenter do
build
(
:alert_management_alert
,
:with_description
,
:with_host
,
:with_service
,
:with_monitoring_tool
,
project:
project
,
payload:
generic_payload
)
build
(
:alert_management_alert
,
:with_description
,
:with_host
,
:with_service
,
:with_monitoring_tool
,
project:
project
,
payload:
generic_payload
)
end
end
let
(
:alert_url
)
{
"http://localhost/
#{
project
.
full_path
}
/-/alert_management/
#{
alert
.
id
}
/details"
}
let
(
:alert_url
)
{
"http://localhost/
#{
project
.
full_path
}
/-/alert_management/
#{
alert
.
i
i
d
}
/details"
}
subject
(
:presenter
)
{
described_class
.
new
(
alert
)
}
subject
(
:presenter
)
{
described_class
.
new
(
alert
)
}
...
...
spec/presenters/alert_management/prometheus_alert_presenter_spec.rb
View file @
4d2caa25
...
@@ -20,7 +20,7 @@ RSpec.describe AlertManagement::PrometheusAlertPresenter do
...
@@ -20,7 +20,7 @@ RSpec.describe AlertManagement::PrometheusAlertPresenter do
create
(
:alert_management_alert
,
:prometheus
,
project:
project
,
payload:
payload
)
create
(
:alert_management_alert
,
:prometheus
,
project:
project
,
payload:
payload
)
end
end
let
(
:alert_url
)
{
"http://localhost/
#{
project
.
full_path
}
/-/alert_management/
#{
alert
.
id
}
/details"
}
let
(
:alert_url
)
{
"http://localhost/
#{
project
.
full_path
}
/-/alert_management/
#{
alert
.
i
i
d
}
/details"
}
subject
(
:presenter
)
{
described_class
.
new
(
alert
)
}
subject
(
:presenter
)
{
described_class
.
new
(
alert
)
}
...
...
spec/presenters/projects/prometheus/alert_presenter_spec.rb
View file @
4d2caa25
...
@@ -300,9 +300,9 @@ RSpec.describe Projects::Prometheus::AlertPresenter do
...
@@ -300,9 +300,9 @@ RSpec.describe Projects::Prometheus::AlertPresenter do
context
'alert management alert present'
do
context
'alert management alert present'
do
let_it_be
(
:am_alert
)
{
create
(
:alert_management_alert
,
project:
project
)
}
let_it_be
(
:am_alert
)
{
create
(
:alert_management_alert
,
project:
project
)
}
let
(
:alert
)
{
create
(
:alerting_alert
,
project:
project
,
payload:
payload
,
alert:
am_alert
)
}
let
(
:alert
)
{
create
(
:alerting_alert
,
project:
project
,
payload:
payload
,
a
m_a
lert:
am_alert
)
}
it
{
is_expected
.
to
eq
(
"http://localhost/
#{
project
.
full_path
}
/-/alert_management/
#{
am_alert
.
id
}
/details"
)
}
it
{
is_expected
.
to
eq
(
"http://localhost/
#{
project
.
full_path
}
/-/alert_management/
#{
am_alert
.
i
i
d
}
/details"
)
}
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