Skip to content

Commit

Permalink
Don't output results heading if there are none
Browse files Browse the repository at this point in the history
Fix a little text output glitch when --show-successes is not set.

Note: I realized that `or` in a go template can take more than two
parameters, so that's why the nested or was removed.

Drive-by fix while working on...
Ref: https://issues.redhat.com/browse/EC-758
  • Loading branch information
simonbaird committed Aug 28, 2024
1 parent c97bb5c commit 902d6ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/validate/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,6 @@ func TestValidateImageDefaultOutput(t *testing.T) {
Component: Unnamed
ImageRef: registry/image:tag
Results:
`)

cases := []struct {
Expand All @@ -1254,6 +1253,7 @@ func TestValidateImageDefaultOutput(t *testing.T) {
{
args: append(commonArgs, "--show-successes"),
expected: fmt.Sprintf("%s%s", commonOutput, hd.Doc(`
Results:
✓ [Success] policy.nice
ImageRef: registry/image:tag
Title: Very nice
Expand Down
2 changes: 1 addition & 1 deletion internal/applicationsnapshot/templates/text_report.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Result: {{ $t.Result }}
Violations: {{ $t.Failures }}, Warnings: {{ $t.Warnings }}, Successes: {{ $t.Successes }}{{ nl -}}

{{- template "_components.tmpl" $c -}}
{{- if or (or (gt $t.Failures 0) (gt $t.Warnings 0)) (gt $t.Successes 0) -}}
{{- if or (gt $t.Failures 0) (gt $t.Warnings 0) (and (gt $t.Successes 0) $r.ShowSuccesses) -}}
Results:{{ nl -}}
{{- if gt $t.Failures 0 -}}
{{- template "_results.tmpl" (toMap "Components" $c "Type" "Violation") -}}
Expand Down

0 comments on commit 902d6ec

Please sign in to comment.