Skip to content

Commit

Permalink
feat(opsgenie): Add support for setting priority in Opsgenie notifica…
Browse files Browse the repository at this point in the history
…tions

Signed-off-by: Bofa Alsarah <[email protected]>
  • Loading branch information
Mustafa Mabrook authored and bofaalsarah committed Feb 8, 2024
1 parent c0913e2 commit 595b339
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/services/opsgenie.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type OpsgenieOptions struct {

type OpsgenieNotification struct {
Description string `json:"description"`
Priority string `json:"priority,omitempty"`
}

func (n *OpsgenieNotification) GetTemplater(name string, f texttemplate.FuncMap) (Templater, error) {
Expand Down Expand Up @@ -63,13 +64,25 @@ func (s *opsgenieService) Send(notification Notification, dest Destination) erro
},
})
description := ""
priority := ""

Check warning on line 67 in pkg/services/opsgenie.go

View check run for this annotation

Codecov / codecov/patch

pkg/services/opsgenie.go#L67

Added line #L67 was not covered by tests
if notification.Opsgenie != nil {
if notification.Opsgenie.Description == "" {
return fmt.Errorf("Opsgenie notification description is missing")
}

Check warning on line 71 in pkg/services/opsgenie.go

View check run for this annotation

Codecov / codecov/patch

pkg/services/opsgenie.go#L69-L71

Added lines #L69 - L71 were not covered by tests

description = notification.Opsgenie.Description

if notification.Opsgenie.Priority != "" {
priority = notification.Opsgenie.Priority
}

Check warning on line 77 in pkg/services/opsgenie.go

View check run for this annotation

Codecov / codecov/patch

pkg/services/opsgenie.go#L74-L77

Added lines #L74 - L77 were not covered by tests
}

alertPriority := alert.Priority(priority)

Check warning on line 81 in pkg/services/opsgenie.go

View check run for this annotation

Codecov / codecov/patch

pkg/services/opsgenie.go#L80-L81

Added lines #L80 - L81 were not covered by tests
_, err := alertClient.Create(context.TODO(), &alert.CreateAlertRequest{
Message: notification.Message,
Description: description,
Priority: alertPriority,

Check warning on line 85 in pkg/services/opsgenie.go

View check run for this annotation

Codecov / codecov/patch

pkg/services/opsgenie.go#L85

Added line #L85 was not covered by tests
Responders: []alert.Responder{
{
Type: "team",
Expand Down

0 comments on commit 595b339

Please sign in to comment.