Skip to content

Commit

Permalink
Always print the number of detected problems
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Mar 3, 2022
1 parent 5655d63 commit c7172b7
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cmd/pint/lint.go
Expand Up @@ -72,8 +72,10 @@ func actionLint(c *cli.Context) (err error) {
problems += c
}
}
if problems > 0 {
if len(bySeverity) > 0 {
log.Info().Fields(bySeverity).Msg("Problems found")
}
if problems > 0 {
return fmt.Errorf("problems found")
}

Expand Down
1 change: 1 addition & 0 deletions cmd/pint/tests/0012_issue_20.txt
Expand Up @@ -11,6 +11,7 @@ rules/1.yaml:9-13: runbook_url annotation is required (alerts/annotation)
summary: "HAProxy server healthcheck failure (instance {{ $labels.instance }})"
description: "Some server healthcheck are failing on {{ $labels.server }}\n VALUE = {{ $value }}\n LABELS: {{ $labels }}"

level=info msg="Problems found" Warning=1
-- rules/1.yaml --
groups:
- name: "haproxy.api_server.rules"
Expand Down
1 change: 1 addition & 0 deletions cmd/pint/tests/0018_match_alerting.txt
Expand Up @@ -15,6 +15,7 @@ rules/0001.yml:5: alert query doesn't have any condition, it will always fire if
rules/0001.yml:5: job label is required and should be preserved when aggregating "^.+$" rules, remove job from without() (promql/aggregate)
expr: sum(bar) without(job)

level=info msg="Problems found" Warning=2
-- rules/0001.yml --
- record: "colo:recording"
expr: sum(foo) without(job)
Expand Down
1 change: 1 addition & 0 deletions cmd/pint/tests/0019_match_recording.txt
Expand Up @@ -12,6 +12,7 @@ level=debug msg="Configured checks for rule" enabled=["promql/syntax","alerts/fo
rules/0001.yml:2: job label is required and should be preserved when aggregating "^.+$" rules, remove job from without() (promql/aggregate)
expr: sum(foo) without(job)

level=info msg="Problems found" Warning=1
-- rules/0001.yml --
- record: "colo:recording"
expr: sum(foo) without(job)
Expand Down
1 change: 1 addition & 0 deletions cmd/pint/tests/0020_ignore_kind.txt
Expand Up @@ -15,6 +15,7 @@ rules/0001.yml:2: job label is required and should be preserved when aggregating
rules/0001.yml:5: alert query doesn't have any condition, it will always fire if the metric exists (alerts/comparison)
expr: sum(bar) without(job)

level=info msg="Problems found" Warning=2
-- rules/0001.yml --
- record: "colo:recording"
expr: sum(foo) without(job)
Expand Down
1 change: 1 addition & 0 deletions cmd/pint/tests/0022_ignore_multi.txt
Expand Up @@ -11,6 +11,7 @@ rules/1.yaml:2: dropped label should be removed when aggregating "^.+$" rules, r
rules/1.yaml:5: keep label is required and should be preserved when aggregating "^.+$" rules, remove keep from without() (promql/aggregate)
expr: sum(errors_total) without(keep,dropped)

level=info msg="Problems found" Warning=2
-- rules/1.yaml --
- record: disabled
expr: sum(errors_total) by(keep,dropped)
Expand Down
1 change: 1 addition & 0 deletions cmd/pint/tests/0037_disable_checks.txt
Expand Up @@ -8,6 +8,7 @@ level=info msg="File parsed" path=rules/0001.yml rules=3
rules/0001.yml:6: job label is required and should be preserved when aggregating "^.+$" rules, use by(job, ...) (promql/aggregate)
expr: sum(foo)

level=info msg="Problems found" Warning=1
-- rules/0001.yml --
- alert: default-for
expr: foo > 1
Expand Down
1 change: 1 addition & 0 deletions cmd/pint/tests/0038_disable_checks_regex.txt
Expand Up @@ -8,6 +8,7 @@ level=info msg="File parsed" path=rules/0001.yml rules=3
rules/0001.yml:6: job label is required and should be preserved when aggregating "^.+$" rules, use by(job, ...) (promql/aggregate)
expr: sum(foo)

level=info msg="Problems found" Warning=1
-- rules/0001.yml --
- alert: default-for
expr: foo > 1
Expand Down
1 change: 1 addition & 0 deletions cmd/pint/tests/0039_prom_selected_path.txt
Expand Up @@ -14,6 +14,7 @@ level=debug msg="Configured checks for rule" enabled=["promql/syntax","alerts/fo
rules/0001.yml:6: job label is required and should be preserved when aggregating "^.+$" rules, use by(job, ...) (promql/aggregate)
expr: sum(bar)

level=info msg="Problems found" Warning=1
-- rules/0001.yml --
- alert: first
expr: foo > 1
Expand Down
1 change: 1 addition & 0 deletions cmd/pint/tests/0040_rule_match_label.txt
Expand Up @@ -19,6 +19,7 @@ rules/rules.yml:5: job label is required and should be preserved when aggregatin
rules/rules.yml:13: job label is required and should be preserved when aggregating "^.*$" rules, use by(job, ...) (promql/aggregate)
expr: sum(foo) > 0

level=info msg="Problems found" Warning=2
-- rules/rules.yml --
- record: ignore
expr: sum(foo)
Expand Down
1 change: 1 addition & 0 deletions cmd/pint/tests/0052_match_multiple.txt
Expand Up @@ -15,6 +15,7 @@ rules/0001.yml:2: job label is required and should be preserved when aggregating
rules/0001.yml:5: job label is required and should be preserved when aggregating "^.+$" rules, remove job from without() (promql/aggregate)
expr: sum(bar) without(job) > 0

level=info msg="Problems found" Warning=2
-- rules/0001.yml --
- record: "colo:recording"
expr: sum(foo) without(job)
Expand Down
2 changes: 1 addition & 1 deletion cmd/pint/tests/0056_prometheus_required.txt
Expand Up @@ -2,7 +2,7 @@ pint.ok -l debug --no-color lint rules
! stdout .
stderr 'level=error msg=\"Query failed" error=\"Post \\"https:///api/v1/query\\": http: no Host in request URL\" query=count\(up\) uri=https://'
stderr 'level=error msg=\"Failed to query Prometheus configuration\" error=\"Get \\"https:///api/v1/status/config\\": http: no Host in request URL\" uri=https://'
! stderr 'level=info msg="Problems found"'
stderr 'level=info msg="Problems found" Warning=8'

-- rules/1.yaml --
- record: one
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.md
@@ -1,5 +1,11 @@
# Changelog

## v0.14.1

### Changed

- Always print the number of detected problems when running `pint lint`.

## v0.14.0

### Added
Expand Down

0 comments on commit c7172b7

Please sign in to comment.