fine-tune text logging

This commit is contained in:
Yann Hamon 2020-10-18 12:57:17 +02:00
parent 52437c00d1
commit 5920cccf07
2 changed files with 6 additions and 2 deletions

View file

@ -43,7 +43,7 @@
@test "Return relevant error for non-existent file" { @test "Return relevant error for non-existent file" {
run bin/kubeconform fixtures/not-here run bin/kubeconform fixtures/not-here
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[ "$output" = "fixtures/not-here - failed validation: open fixtures/not-here: no such file or directory" ] [ "$output" = "fixtures/not-here - failed validation: open fixtures/not-here: no such file or directory" ]
} }
@test "Fail when parsing a config with additional properties and strict set" { @test "Fail when parsing a config with additional properties and strict set" {

View file

@ -46,7 +46,11 @@ func (o *text) Write(filename, kind, name, version string, reserr error, skipped
_, err = fmt.Fprintf(o.w, "%s - %s %s is invalid: %s\n", filename, kind, name, reserr) _, err = fmt.Fprintf(o.w, "%s - %s %s is invalid: %s\n", filename, kind, name, reserr)
o.nInvalid++ o.nInvalid++
case ERROR: case ERROR:
_, err = fmt.Fprintf(o.w, "%s - %s %s failed validation: %s\n", filename, kind, name, reserr) if kind != "" && name != "" {
_, err = fmt.Fprintf(o.w, "%s - %s %s failed validation: %s\n", filename, kind, name, reserr)
} else {
_, err = fmt.Fprintf(o.w, "%s - failed validation: %s\n", filename, reserr)
}
o.nErrors++ o.nErrors++
case SKIPPED: case SKIPPED:
if o.verbose { if o.verbose {