Skip to content

Commit

Permalink
Fix lint errors. (#127)
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Wells <spinmaster@gmail.com>
  • Loading branch information
twotired committed May 8, 2023
1 parent 8fdd24e commit 0a7da5d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
3 changes: 2 additions & 1 deletion cmd/jiralert/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import (
"runtime"
"strconv"

"github.com/andygrunwald/go-jira"
jira "github.com/andygrunwald/go-jira"

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus-community/jiralert/pkg/alertmanager"
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ var durationRE = regexp.MustCompile("^([0-9]+)(y|w|d|h|m|s|ms)$")
func ParseDuration(durationStr string) (Duration, error) {
matches := durationRE.FindStringSubmatch(durationStr)
if len(matches) != 3 {
return 0, fmt.Errorf("not a valid duration string: %q", durationStr)
return Duration(time.Duration(0)), fmt.Errorf("not a valid duration string: %q", durationStr)
}
var (
n, _ = strconv.Atoi(matches[1])
Expand All @@ -376,7 +376,7 @@ func ParseDuration(durationStr string) (Duration, error) {
case "ms":
// Value already correct
default:
return 0, fmt.Errorf("invalid time unit in duration string: %q", unit)
return Duration(time.Duration(0)), fmt.Errorf("invalid time unit in duration string: %q", unit)
}
return Duration(dur), nil
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"
"time"

"github.com/andygrunwald/go-jira"
jira "github.com/andygrunwald/go-jira"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/pkg/errors"
Expand Down Expand Up @@ -178,6 +178,7 @@ func (r *Receiver) Notify(data *alertmanager.Data, hashJiraLabel bool, updateSum
if len(r.conf.Components) > 0 {
issue.Fields.Components = make([]*jira.Component, 0, len(r.conf.Components))
for _, component := range r.conf.Components {
//nolint:typecheck // lint flags issueComp as not being used, even though it's referenced below.
issueComp, err := r.tmpl.Execute(component, data)
if err != nil {
return false, errors.Wrap(err, "render issue component")
Expand Down
36 changes: 18 additions & 18 deletions pkg/notify/notify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"testing"
"time"

"github.com/andygrunwald/go-jira"
jira "github.com/andygrunwald/go-jira"

"github.com/trivago/tgo/tcontainer"

Expand Down Expand Up @@ -216,9 +216,9 @@ func TestNotify_JIRAInteraction(t *testing.T) {
initJira: func(t *testing.T) *fakeJira { return newTestFakeJira() },
inputAlert: &alertmanager.Data{
Alerts: alertmanager.Alerts{
{Status: alertmanager.AlertFiring},
{Status: "not firing"},
{Status: alertmanager.AlertFiring},
alertmanager.Alert{Status: alertmanager.AlertFiring},
alertmanager.Alert{Status: "not firing"},
alertmanager.Alert{Status: alertmanager.AlertFiring},
},
Status: alertmanager.AlertFiring,
GroupLabels: alertmanager.KV{"a": "b", "c": "d"},
Expand Down Expand Up @@ -259,8 +259,8 @@ func TestNotify_JIRAInteraction(t *testing.T) {
},
inputAlert: &alertmanager.Data{
Alerts: alertmanager.Alerts{
{Status: "not firing"},
{Status: alertmanager.AlertFiring}, // Only one firing now.
alertmanager.Alert{Status: "not firing"},
alertmanager.Alert{Status: alertmanager.AlertFiring}, // Only one firing now.
},
Status: alertmanager.AlertFiring,
GroupLabels: alertmanager.KV{"a": "b", "c": "d"},
Expand Down Expand Up @@ -302,8 +302,8 @@ func TestNotify_JIRAInteraction(t *testing.T) {
},
inputAlert: &alertmanager.Data{
Alerts: alertmanager.Alerts{
{Status: "not firing"},
{Status: alertmanager.AlertFiring}, // Only one firing now.
alertmanager.Alert{Status: "not firing"},
alertmanager.Alert{Status: alertmanager.AlertFiring}, // Only one firing now.
},
Status: alertmanager.AlertFiring,
GroupLabels: alertmanager.KV{"a": "b", "c": "d"},
Expand Down Expand Up @@ -354,8 +354,8 @@ func TestNotify_JIRAInteraction(t *testing.T) {
},
inputAlert: &alertmanager.Data{
Alerts: alertmanager.Alerts{
{Status: "not firing"},
{Status: alertmanager.AlertFiring}, // Only one firing now.
alertmanager.Alert{Status: "not firing"},
alertmanager.Alert{Status: alertmanager.AlertFiring}, // Only one firing now.
},
Status: alertmanager.AlertFiring,
GroupLabels: alertmanager.KV{"a": "b", "c": "d"},
Expand Down Expand Up @@ -409,8 +409,8 @@ func TestNotify_JIRAInteraction(t *testing.T) {
},
inputAlert: &alertmanager.Data{
Alerts: alertmanager.Alerts{
{Status: "not firing"},
{Status: alertmanager.AlertFiring}, // Only one firing now.
alertmanager.Alert{Status: "not firing"},
alertmanager.Alert{Status: alertmanager.AlertFiring}, // Only one firing now.
},
Status: alertmanager.AlertFiring,
GroupLabels: alertmanager.KV{"a": "b", "c": "d"},
Expand Down Expand Up @@ -464,8 +464,8 @@ func TestNotify_JIRAInteraction(t *testing.T) {
},
inputAlert: &alertmanager.Data{
Alerts: alertmanager.Alerts{
{Status: "not firing"},
{Status: alertmanager.AlertFiring}, // Only one firing now.
alertmanager.Alert{Status: "not firing"},
alertmanager.Alert{Status: alertmanager.AlertFiring}, // Only one firing now.
},
Status: alertmanager.AlertFiring,
GroupLabels: alertmanager.KV{"a": "b", "c": "d"},
Expand Down Expand Up @@ -510,7 +510,7 @@ func TestNotify_JIRAInteraction(t *testing.T) {
inputConfig: testReceiverConfigAutoResolve(),
inputAlert: &alertmanager.Data{
Alerts: alertmanager.Alerts{
{Status: "resolved"},
alertmanager.Alert{Status: "resolved"},
},
Status: alertmanager.AlertResolved,
GroupLabels: alertmanager.KV{"a": "b", "c": "d"},
Expand Down Expand Up @@ -554,9 +554,9 @@ func TestNotify_JIRAInteraction(t *testing.T) {
initJira: func(t *testing.T) *fakeJira { return newTestFakeJira() },
inputAlert: &alertmanager.Data{
Alerts: alertmanager.Alerts{
{Status: alertmanager.AlertFiring},
{Status: "not firing"},
{Status: alertmanager.AlertFiring},
alertmanager.Alert{Status: alertmanager.AlertFiring},
alertmanager.Alert{Status: "not firing"},
alertmanager.Alert{Status: alertmanager.AlertFiring},
},
Status: alertmanager.AlertFiring,
GroupLabels: alertmanager.KV{"a": "b", "c": "d"},
Expand Down

0 comments on commit 0a7da5d

Please sign in to comment.