fix(backend): run make format

This commit is contained in:
Łukasz Mierzwa
2026-05-12 16:01:43 +01:00
committed by Łukasz Mierzwa
parent 799f2cc2c1
commit 0b68886c43
10 changed files with 37 additions and 19 deletions

View File

@@ -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)
}

View File

@@ -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,
),
}),
},
},

View File

@@ -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

View File

@@ -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

View File

@@ -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"},
}),

View File

@@ -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 {

View File

@@ -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{},

View File

@@ -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")
}

View File

@@ -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)
}

View File

@@ -231,7 +231,8 @@ func TestStripReceivers(t *testing.T) {
if stripped != testCase.stripped {
t.Errorf("StripReceivers failed, expected %v, got %v", testCase.stripped, stripped)
}
})
},
)
}
}