diff --git a/cmd/karma/alert_history.go b/cmd/karma/alert_history.go index 4a7c543dc..ee49cae66 100644 --- a/cmd/karma/alert_history.go +++ b/cmd/karma/alert_history.go @@ -327,7 +327,8 @@ func countAlerts(uri string, timeout time.Duration, transport http.RoundTripper, ctx, []string{`{__name__="ALERTS_FOR_STATE"}`}, time.Now().Add(time.Minute*-5), - time.Now()) + time.Now(), + ) if err != nil { return nil, fmt.Errorf("failed to query Prometheus for label names: %w", err) } diff --git a/cmd/karma/alert_history_test.go b/cmd/karma/alert_history_test.go index 1565a36df..f504c9df0 100644 --- a/cmd/karma/alert_history_test.go +++ b/cmd/karma/alert_history_test.go @@ -191,7 +191,8 @@ func TestAlertHistory(t *testing.T) { }, values: generateIntSlice(0, 1, 24), }, - }, time.Hour), + }, time.Hour, + ), }), }, }, @@ -302,7 +303,8 @@ func TestAlertHistory(t *testing.T) { }, values: generateIntSlice(0, 1, 24), }, - }, time.Hour), + }, time.Hour, + ), }), }, }, @@ -373,7 +375,8 @@ func TestAlertHistory(t *testing.T) { }, values: generateIntSlice(0, 1, 24), }, - }, time.Hour), + }, time.Hour, + ), }), }, }, @@ -432,7 +435,8 @@ func TestAlertHistory(t *testing.T) { }, values: generateIntSlice(0, 1, 24), }, - }, time.Hour), + }, time.Hour, + ), }), }, }, @@ -491,7 +495,8 @@ func TestAlertHistory(t *testing.T) { }, values: generateIntSlice(0, 1, 24), }, - }, time.Hour), + }, time.Hour, + ), }), }, }, @@ -559,7 +564,8 @@ func TestAlertHistory(t *testing.T) { }, values: generateIntSlice(0, 1, 24), }, - }, time.Hour), + }, time.Hour, + ), }), }, }, diff --git a/cmd/karma/proxy.go b/cmd/karma/proxy.go index 3fc4793d9..e1d11d132 100644 --- a/cmd/karma/proxy.go +++ b/cmd/karma/proxy.go @@ -177,13 +177,15 @@ func setupRouterProxyHandlers(router *chi.Mux, alertmanager *alertmanager.Alertm proxy := NewAlertmanagerProxy(alertmanager) router.Post( proxyPath(alertmanager.Name, "/api/v2/silences"), - handlePostRequest(alertmanager, http.StripPrefix(proxyPathPrefix(alertmanager.Name), proxy))) + handlePostRequest(alertmanager, http.StripPrefix(proxyPathPrefix(alertmanager.Name), proxy)), + ) router.Delete( proxyPath(alertmanager.Name, "/api/v2/silence/{id}"), http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { h := http.StripPrefix(proxyPathPrefix(alertmanager.Name), proxy) h.ServeHTTP(w, r) - })) + }), + ) } // this fixes a problem with go-chi usage of RawPath diff --git a/internal/alertmanager/dedup.go b/internal/alertmanager/dedup.go index 365c23e00..b70dcb3bb 100644 --- a/internal/alertmanager/dedup.go +++ b/internal/alertmanager/dedup.go @@ -95,14 +95,16 @@ func DedupAlerts() []models.AlertGroup { ag.Labels = transform.StripLabels( config.Config.Labels.Keep, config.Config.Labels.Strip, config.Config.Labels.CompiledKeepRegex, config.Config.Labels.CompiledStripRegex, - ag.Labels) + ag.Labels, + ) ag.Alerts = make(models.AlertList, 0, len(alerts)) for _, alert := range alerts { // strip labels and annotations user doesn't want to see in the UI alert.Labels = transform.StripLabels( config.Config.Labels.Keep, config.Config.Labels.Strip, config.Config.Labels.CompiledKeepRegex, config.Config.Labels.CompiledStripRegex, - alert.Labels) + alert.Labels, + ) alert.Annotations = transform.StripAnnotations(config.Config.Annotations.Keep, config.Config.Annotations.Strip, alert.Annotations) // calculate final alert state based on the most important value found // in the list of states from all instances diff --git a/internal/alertmanager/models_test.go b/internal/alertmanager/models_test.go index 2b5ca3168..ae8da4043 100644 --- a/internal/alertmanager/models_test.go +++ b/internal/alertmanager/models_test.go @@ -274,7 +274,8 @@ func TestProbeVersionInvalidMetrics(t *testing.T) { func TestIsHealthCheckAlertAllMatch(t *testing.T) { // verifies that an alert matching all healthcheck filters is identified as a healthcheck - am, err := NewAlertmanager("cluster", "hc-test", "http://localhost", + am, err := NewAlertmanager( + "cluster", "hc-test", "http://localhost", WithHealthchecks(map[string][]string{ "prom1": {"alertname=Watchdog"}, }), @@ -297,7 +298,8 @@ func TestIsHealthCheckAlertAllMatch(t *testing.T) { func TestIsHealthCheckAlertPartialMatch(t *testing.T) { // verifies that an alert matching only some healthcheck filters is NOT identified as a healthcheck - am, err := NewAlertmanager("cluster", "hc-test-partial", "http://localhost", + am, err := NewAlertmanager( + "cluster", "hc-test-partial", "http://localhost", WithHealthchecks(map[string][]string{ "prom1": {"alertname=Watchdog", "severity=critical"}, }), @@ -320,7 +322,8 @@ func TestIsHealthCheckAlertPartialMatch(t *testing.T) { func TestIsHealthCheckAlertNoMatch(t *testing.T) { // verifies that an alert not matching any healthcheck filters returns empty result - am, err := NewAlertmanager("cluster", "hc-test-none", "http://localhost", + am, err := NewAlertmanager( + "cluster", "hc-test-none", "http://localhost", WithHealthchecks(map[string][]string{ "prom1": {"alertname=Watchdog"}, }), diff --git a/internal/alertmanager/upstream_test.go b/internal/alertmanager/upstream_test.go index ec6a07c75..2e669d373 100644 --- a/internal/alertmanager/upstream_test.go +++ b/internal/alertmanager/upstream_test.go @@ -195,7 +195,8 @@ func TestGetAlertmanagerByName(t *testing.T) { func TestWithHealthchecksVisible(t *testing.T) { // verifies that WithHealthchecksVisible sets the healthchecksVisible field - am, err := NewAlertmanager("cluster", "hcv-test", "http://localhost", + am, err := NewAlertmanager( + "cluster", "hcv-test", "http://localhost", WithHealthchecksVisible(true), ) if err != nil { diff --git a/internal/config/config.go b/internal/config/config.go index 85f96a13c..5d3533227 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -69,7 +69,8 @@ func SetupFlags(f *pflag.FlagSet) { f.Bool( "annotations.default.hidden", false, - "Hide all annotations by default unless explicitly listed in the 'visible' list") + "Hide all annotations by default unless explicitly listed in the 'visible' list", + ) f.StringSlice("annotations.hidden", []string{}, "List of annotations that are hidden by default") f.StringSlice("annotations.visible", []string{}, diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 1c9fa38ae..28a225fc2 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -429,7 +429,7 @@ func TestDefaultConfig(t *testing.T) { } func TestValidateConfigMissingFile(t *testing.T) { - err := validateConfigFile(("/foo/bar/xxx/yyy.yaml")) + err := validateConfigFile("/foo/bar/xxx/yyy.yaml") if err == nil { t.Errorf("validateConfigFile didn't return any error") } diff --git a/internal/filters/filter_test.go b/internal/filters/filter_test.go index 2867d4f75..4f1da1dd1 100644 --- a/internal/filters/filter_test.go +++ b/internal/filters/filter_test.go @@ -1095,7 +1095,8 @@ func TestFilters(t *testing.T) { if f.Valid() { isAlertmanagerFilter := slices.Contains( []string{"@age", "@alertmanager", "@cluster", "@inhibited", "@inhibited_by", "@state", "@silenced_by", "@silence_ticket", "@silence_author", "@fingerprint"}, - f.Name()) + f.Name(), + ) if isAlertmanagerFilter != f.IsAlertmanagerFilter() { t.Errorf("[%s] IsAlertmanagerFilter() returned %#v while %#v was expected", ft.Expression, f.IsAlertmanagerFilter(), isAlertmanagerFilter) } diff --git a/internal/transform/strip_test.go b/internal/transform/strip_test.go index 167802f31..18a7de5a7 100644 --- a/internal/transform/strip_test.go +++ b/internal/transform/strip_test.go @@ -231,7 +231,8 @@ func TestStripReceivers(t *testing.T) { if stripped != testCase.stripped { t.Errorf("StripReceivers failed, expected %v, got %v", testCase.stripped, stripped) } - }) + }, + ) } }