From 0a7da5d42a4fc4735730906a2a6a08b81d29fa03 Mon Sep 17 00:00:00 2001 From: Jason Wells Date: Sun, 28 Aug 2022 08:43:45 -0700 Subject: [PATCH] Fix lint errors. (#127) Signed-off-by: Jason Wells --- cmd/jiralert/main.go | 3 ++- pkg/config/config.go | 4 ++-- pkg/notify/notify.go | 3 ++- pkg/notify/notify_test.go | 36 ++++++++++++++++++------------------ 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/cmd/jiralert/main.go b/cmd/jiralert/main.go index 86be130..6ca9370 100644 --- a/cmd/jiralert/main.go +++ b/cmd/jiralert/main.go @@ -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" diff --git a/pkg/config/config.go b/pkg/config/config.go index 71ba2b8..52da3d5 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -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]) @@ -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 } diff --git a/pkg/notify/notify.go b/pkg/notify/notify.go index ffcc6d8..c254201 100644 --- a/pkg/notify/notify.go +++ b/pkg/notify/notify.go @@ -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" @@ -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") diff --git a/pkg/notify/notify_test.go b/pkg/notify/notify_test.go index 8e73f4a..b5a4f3c 100644 --- a/pkg/notify/notify_test.go +++ b/pkg/notify/notify_test.go @@ -19,7 +19,7 @@ import ( "testing" "time" - "github.com/andygrunwald/go-jira" + jira "github.com/andygrunwald/go-jira" "github.com/trivago/tgo/tcontainer" @@ -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"}, @@ -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"}, @@ -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"}, @@ -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"}, @@ -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"}, @@ -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"}, @@ -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"}, @@ -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"},