diff --git a/.errcheck_excludes.txt b/.errcheck_excludes.txt deleted file mode 100644 index 306a6f6..0000000 --- a/.errcheck_excludes.txt +++ /dev/null @@ -1 +0,0 @@ -(github.com/go-kit/log.Logger).Log diff --git a/cmd/promcheck/check.go b/cmd/promcheck/check.go index fac769e..25cfaa2 100644 --- a/cmd/promcheck/check.go +++ b/cmd/promcheck/check.go @@ -143,6 +143,7 @@ func (app *promcheckApp) checkRules() error { func (app *promcheckApp) checkRulesFromRuleFiles() error { matches, err := filepath.Glob(app.optFilesRegexp) if err != nil { + // nolint: errcheck level.Error(app.logger).Log("msg", "failed to parse rule group file paths", "err", err) return err } @@ -151,6 +152,7 @@ func (app *promcheckApp) checkRulesFromRuleFiles() error { for _, file := range matches { ruleGroups, err := processFile(file) if err != nil { + // nolint: errcheck level.Error(app.logger).Log("msg", "failed to parse rule group files", "err", err) return err } @@ -158,6 +160,7 @@ func (app *promcheckApp) checkRulesFromRuleFiles() error { } if len(ruleGroupsToCheck) == 0 { + // nolint: errcheck level.Error(app.logger).Log("msg", "no rule groups to check. Please check for --check.file flag spelling mistakes") return err } @@ -171,6 +174,7 @@ func (app *promcheckApp) checkRulesFromRuleFiles() error { eg.Go(func() error { checked, err := app.check.CheckRuleGroup(group) if err != nil { + // nolint: errcheck level.Error(app.logger).Log("msg", "failed to check rule groups", "file", group.File, "err", err) return err } @@ -184,6 +188,7 @@ func (app *promcheckApp) checkRulesFromRuleFiles() error { go func() { if err := eg.Wait(); err != nil { + // nolint: errcheck level.Error(app.logger).Log("msg", "failed to check rule groups", "err", err) close(resultChan) return @@ -212,6 +217,7 @@ func (app *promcheckApp) checkRulesFromRuleFiles() error { if hasExpressionsWithoutResult && app.optStrictMode { err := app.report.Dump() if err != nil { + // nolint: errcheck level.Error(app.logger).Log("msg", "failed to print report", "err", err) } os.Exit(1) @@ -260,12 +266,14 @@ func (app *promcheckApp) checkRulesFromPrometheusInstance() error { RoundTripper: app.roundTripper, }) if err != nil { + // nolint: errcheck level.Error(app.logger).Log("msg", "failed to create Prometheus client", "err", err) return err } promAPI := prometheusv1.NewAPI(client) apiResponse, err := promAPI.Rules(context.TODO()) // TODO: Can we somehow only load the ones we're interested in if filtered? if err != nil { + // nolint: errcheck level.Error(app.logger).Log("msg", "failed to receive rules from prometheus instance", "err", err) return err } @@ -276,6 +284,7 @@ func (app *promcheckApp) checkRulesFromPrometheusInstance() error { } if len(ruleGroupsToCheck) == 0 { + // nolint: errcheck level.Error(app.logger).Log("msg", "no rule groups to check. Please check whether the Prometheus instance contains any rules.") return err } @@ -289,6 +298,7 @@ func (app *promcheckApp) checkRulesFromPrometheusInstance() error { eg.Go(func() error { checked, err := app.check.CheckRuleGroup(group) if err != nil { + // nolint: errcheck level.Error(app.logger).Log("msg", "failed to check rule groups", "file", group.File, "err", err) return err } @@ -302,6 +312,7 @@ func (app *promcheckApp) checkRulesFromPrometheusInstance() error { go func() { if err := eg.Wait(); err != nil { + // nolint: errcheck level.Error(app.logger).Log("msg", "failed to check rule groups", "err", err) close(resultChan) return @@ -329,6 +340,7 @@ func (app *promcheckApp) checkRulesFromPrometheusInstance() error { if hasExpressionsWithoutResult && app.optStrictMode { err := app.report.Dump() if err != nil { + // nolint: errcheck level.Error(app.logger).Log("msg", "failed to print report", "err", err) } os.Exit(1) @@ -375,6 +387,7 @@ func (app *promcheckApp) checkRulesFromInlineQueries() error { checkResults := []promcheck.CheckResult{} checked, err := app.check.CheckRuleGroup(group) if err != nil { + // nolint: errcheck level.Error(app.logger).Log("msg", "failed to check rule groups", "file", group.File, "err", err) return err } @@ -399,6 +412,7 @@ func (app *promcheckApp) checkRulesFromInlineQueries() error { if hasExpressionsWithoutResult && app.optStrictMode { err := app.report.Dump() if err != nil { + // nolint: errcheck level.Error(app.logger).Log("msg", "failed to print report", "err", err) } os.Exit(1) diff --git a/cmd/promcheck/main.go b/cmd/promcheck/main.go index 31abeda..04eb2b0 100644 --- a/cmd/promcheck/main.go +++ b/cmd/promcheck/main.go @@ -97,11 +97,13 @@ func main() { // validation if cfg.ExporterInterval < 0 { + // nolint: errcheck level.Error(logger).Log("msg", "configuration error", "err", "--exporter.interval must be > 0") os.Exit(1) } if cfg.CheckDelay < 0 { + // nolint: errcheck level.Error(logger).Log("msg", "configuration error", "err", "--check.delay must be > 0") os.Exit(1) } diff --git a/cmd/promcheck/server.go b/cmd/promcheck/server.go index 6184dd7..e73ca1c 100644 --- a/cmd/promcheck/server.go +++ b/cmd/promcheck/server.go @@ -23,7 +23,7 @@ func (app *promcheckApp) runPromcheckExporter() error { { httpLogger := log.With(app.logger, "component", "exporter") m := http.NewServeMux() - handleHealth := func(w http.ResponseWriter, r *http.Request) { + handleHealth := func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) } m.HandleFunc("/health", handleHealth) @@ -40,7 +40,7 @@ func (app *promcheckApp) runPromcheckExporter() error { Handler: m, } - m.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + m.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(`