Skip to content

Commit

Permalink
feat: add reopen_enabled flag
Browse files Browse the repository at this point in the history
- fixes #120
  • Loading branch information
alikhil committed Nov 30, 2022
1 parent f58ae33 commit 59aeedb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 11 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ type ReceiverConfig struct {
Project string `yaml:"project" json:"project"`
IssueType string `yaml:"issue_type" json:"issue_type"`
Summary string `yaml:"summary" json:"summary"`
ReopenEnabled *bool `yaml:"reopen_enabled" json:"reopen_enabled"`
ReopenState string `yaml:"reopen_state" json:"reopen_state"`
ReopenDuration *Duration `yaml:"reopen_duration" json:"reopen_duration"`

Expand Down Expand Up @@ -212,6 +213,11 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
}

if c.Defaults.ReopenEnabled == nil {
var defaultReopenEnabled = false
c.Defaults.ReopenEnabled = &defaultReopenEnabled
}

for _, rc := range c.Receivers {
if rc.Name == "" {
return fmt.Errorf("missing name for receiver %+v", rc)
Expand Down Expand Up @@ -269,6 +275,11 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
rc.Summary = c.Defaults.Summary
}

if rc.ReopenEnabled == nil {
rc.ReopenEnabled = c.Defaults.ReopenEnabled
}

if rc.ReopenState == "" {
if c.Defaults.ReopenState == "" {
return fmt.Errorf("missing reopen_state in receiver %q", rc.Name)
Expand Down
9 changes: 8 additions & 1 deletion pkg/notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ import (
"bytes"
"crypto/sha512"
"fmt"
"github.com/andygrunwald/go-jira"
"io"
"reflect"
"strings"
"time"

"github.com/andygrunwald/go-jira"

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/pkg/errors"
Expand Down Expand Up @@ -299,6 +300,12 @@ func (r *Receiver) search(project, issueLabel string) (*jira.Issue, bool, error)
}

func (r *Receiver) findIssueToReuse(project string, issueGroupLabel string) (*jira.Issue, bool, error) {

if !*r.conf.ReopenEnabled {
level.Debug(r.logger).Log("msg", "reopening disabled, skipping search for existing issue")
return nil, false, nil
}

issue, retry, err := r.search(project, issueGroupLabel)
if err != nil {
return nil, retry, err
Expand Down

0 comments on commit 59aeedb

Please sign in to comment.