Skip to content

Commit

Permalink
Fix lint errors.
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Wells <[email protected]>
  • Loading branch information
Jason Wells committed Aug 28, 2022
1 parent 43a23d5 commit 389314f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion cmd/jiralert/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"runtime"
"strconv"

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

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
Expand Down
6 changes: 3 additions & 3 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/go-kit/kit/log/level"

"github.com/trivago/tgo/tcontainer"
"gopkg.in/yaml.v2"
yaml "gopkg.in/yaml.v2"
)

// Secret is a string that must not be revealed on marshaling.
Expand Down Expand Up @@ -351,7 +351,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 @@ -373,7 +373,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
2 changes: 1 addition & 1 deletion pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/go-kit/kit/log"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v2"
yaml "gopkg.in/yaml.v2"
)

const testConf = `
Expand Down
3 changes: 2 additions & 1 deletion pkg/notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"strings"
"time"

"github.com/andygrunwald/go-jira"
jira "github.com/andygrunwald/go-jira"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/pkg/errors"
Expand Down Expand Up @@ -164,6 +164,7 @@ func (r *Receiver) Notify(data *alertmanager.Data, hashJiraLabel bool) (bool, er
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
30 changes: 15 additions & 15 deletions pkg/notify/notify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/trivago/tgo/tcontainer"

"github.com/andygrunwald/go-jira"
jira "github.com/andygrunwald/go-jira"
"github.com/go-kit/kit/log"
"github.com/pkg/errors"
"github.com/prometheus-community/jiralert/pkg/alertmanager"
Expand Down Expand Up @@ -203,9 +203,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 @@ -246,8 +246,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 @@ -289,8 +289,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 @@ -341,8 +341,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 @@ -396,8 +396,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 @@ -451,8 +451,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 @@ -497,7 +497,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

0 comments on commit 389314f

Please sign in to comment.