mirror of
https://github.com/prymitive/karma
synced 2026-08-23 11:56:20 +00:00
fix(backend): fix problems found by new linters
This commit is contained in:
@@ -31,6 +31,7 @@ func DedupAlerts() []models.AlertGroup {
|
||||
alerts := map[string]models.Alert{}
|
||||
for _, ag := range agList {
|
||||
for _, alert := range ag.Alerts {
|
||||
alert := alert // scopelint pin
|
||||
// remove all alerts for receiver(s) that the user doesn't
|
||||
// want to see in the UI
|
||||
if transform.StripReceivers(config.Config.Receivers.Keep, config.Config.Receivers.Strip, alert.Receiver) {
|
||||
@@ -66,6 +67,7 @@ func DedupAlerts() []models.AlertGroup {
|
||||
ag := models.AlertGroup(agList[0])
|
||||
ag.Alerts = models.AlertList{}
|
||||
for _, alert := range alerts {
|
||||
alert := alert // scopelint pin
|
||||
// strip labels and annotations user doesn't want to see in the UI
|
||||
alert.Labels = transform.StripLables(config.Config.Labels.Keep, config.Config.Labels.Strip, alert.Labels)
|
||||
alert.Annotations = transform.StripAnnotations(config.Config.Annotations.Keep, config.Config.Annotations.Strip, alert.Annotations)
|
||||
|
||||
@@ -182,6 +182,7 @@ func (am *Alertmanager) pullSilences(version string) error {
|
||||
log.Infof("[%s] Detecting JIRA links in silences (%d)", am.Name, len(silences))
|
||||
silenceMap := map[string]models.Silence{}
|
||||
for _, silence := range silences {
|
||||
silence := silence // scopelint pin
|
||||
silence.JiraID, silence.JiraURL = transform.DetectJIRAs(&silence)
|
||||
silenceMap[silence.ID] = silence
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ import (
|
||||
type filterTest struct {
|
||||
Expression string
|
||||
IsValid bool
|
||||
IsMatch bool
|
||||
Alert models.Alert
|
||||
Silence models.Silence
|
||||
IsMatch bool
|
||||
}
|
||||
|
||||
var tests = []filterTest{
|
||||
|
||||
@@ -153,9 +153,12 @@ var agFPTests = []agFPTest{
|
||||
func TestAlertGroupContentFingerprint(t *testing.T) {
|
||||
fps := []string{}
|
||||
for i, testCase := range agFPTests {
|
||||
i := i // scopelint pin
|
||||
testCase := testCase // scopelint pin
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
alerts := models.AlertList{}
|
||||
for _, alert := range testCase.ag.Alerts {
|
||||
alert := alert // scopelint pin
|
||||
alert.UpdateFingerprints()
|
||||
alerts = append(alerts, alert)
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ func getFileSize(path string) int64 {
|
||||
|
||||
type httpTransportTest struct {
|
||||
timeout time.Duration
|
||||
useTLS bool
|
||||
tlsConfig *tls.Config
|
||||
useTLS bool
|
||||
failed bool
|
||||
headers map[string]string
|
||||
}
|
||||
|
||||
@@ -178,6 +178,7 @@ func TestProxyHeaders(t *testing.T) {
|
||||
defer httpmock.DeactivateAndReset()
|
||||
|
||||
for _, testCase := range proxyHeaderTests {
|
||||
testCase := testCase //scopelint pin
|
||||
r := ginTestEngine()
|
||||
am, err := alertmanager.NewAlertmanager(
|
||||
"dummy",
|
||||
|
||||
Reference in New Issue
Block a user