From 98f8308bbd424788604700241276ed72025b4821 Mon Sep 17 00:00:00 2001 From: Jason Wells Date: Tue, 30 Jan 2024 12:28:38 -0800 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Bartlomiej Plotka Signed-off-by: Jason Wells --- examples/jiralert.yml | 6 +++++- pkg/notify/notify.go | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/jiralert.yml b/examples/jiralert.yml index c0216dc..1a35b7a 100644 --- a/examples/jiralert.yml +++ b/examples/jiralert.yml @@ -25,7 +25,11 @@ defaults: reopen_duration: 0h # Static label that will be added to the JIRA ticket alongisde the JIRALERT{...} or ALERT{...} label static_labels: ["custom"] - # Other projects that issues may be moved to and further updates are desired + # Other projects are the projects to search for existing issues for the given alerts if + # the main project does not have it. If no issue was found in, the main projects will + # be used to create a new one. If the old issue is found in one of the other projects + # (first found is used in case of duplicates) that old project's issue will be used for + # alert updates instead of creating on in the main project. other_projects: ["OTHER1", "OTHER2"] # Receiver definitions. At least one must be defined. diff --git a/pkg/notify/notify.go b/pkg/notify/notify.go index 8c07bbf..26d974f 100644 --- a/pkg/notify/notify.go +++ b/pkg/notify/notify.go @@ -289,7 +289,7 @@ func toGroupTicketLabel(groupLabels alertmanager.KV, hashJiraLabel bool) string } func (r *Receiver) search(projects []string, issueLabel string) (*jira.Issue, bool, error) { - // search multiple projects in case issue was moved and further alert firings are desired in existing JIRA + // Search multiple projects in case issue was moved and further alert firings are desired in existing JIRA. projectList := "'" + strings.Join(projects, "', '") + "'" query := fmt.Sprintf("project in(%s) and labels=%q order by resolutiondate desc", projectList, issueLabel) options := &jira.SearchOptions{ @@ -320,7 +320,7 @@ func (r *Receiver) search(projects []string, issueLabel string) (*jira.Issue, bo func (r *Receiver) findIssueToReuse(project string, issueGroupLabel string) (*jira.Issue, bool, error) { projectsToSearch := []string{project} - // in case issue was moved to a different project, include configured potential other projects in search + // In case issue was moved to a different project, include the other configured projects in search (if any). for _, other := range r.conf.OtherProjects { if other != project { projectsToSearch = append(projectsToSearch, other)